Mercurial > hg > openmind
comparison src/main/java/org/mpi/openmind/repository/services/PersistenceService.java @ 26:5e24413d355b
Fixed bug that deleted all attributes in the system if a relation had id=null :-(
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 05 Aug 2016 22:02:18 +0200 |
parents | 165b1efb85cd |
children | 1cd9d9a67cad |
comparison
equal
deleted
inserted
replaced
25:c23ae718fdd3 | 26:5e24413d355b |
---|---|
297 relations = list; | 297 relations = list; |
298 } | 298 } |
299 | 299 |
300 // loading attributes | 300 // loading attributes |
301 for (Relation rel : relations) { | 301 for (Relation rel : relations) { |
302 // FIXME: getNodes finds all attributes if id=null! | |
303 if (rel.getId() == null) { | |
304 logger.error("Relation with id=null! Abort loading attributes."); | |
305 continue; | |
306 } | |
302 List<Node> attrs = this.getNodes(session, null, | 307 List<Node> attrs = this.getNodes(session, null, |
303 rel.getSystemStatus(), rel.getId(), | 308 rel.getSystemStatus(), rel.getId(), |
304 rel.getModificationTime(), null, null); | 309 rel.getModificationTime(), null, null); |
305 for (Node attNode : attrs) { | 310 for (Node attNode : attrs) { |
306 if (attNode instanceof Attribute) { | 311 if (attNode instanceof Attribute) { |
526 } else { | 531 } else { |
527 relations = list; | 532 relations = list; |
528 } | 533 } |
529 // loading attributes | 534 // loading attributes |
530 for (Relation rel : relations) { | 535 for (Relation rel : relations) { |
536 // FIXME: getNodes finds all attributes if id=null! | |
537 if (rel.getId() == null) { | |
538 logger.error("Relation with id=null! Abort loading attributes."); | |
539 continue; | |
540 } | |
531 List<Node> attrs = this.getNodes(session, null, | 541 List<Node> attrs = this.getNodes(session, null, |
532 rel.getSystemStatus(), rel.getId(), | 542 rel.getSystemStatus(), rel.getId(), |
533 rel.getModificationTime(), null, null); | 543 rel.getModificationTime(), null, null); |
534 for (Node attNode : attrs) { | 544 for (Node attNode : attrs) { |
535 if (attNode instanceof Attribute) { | 545 if (attNode instanceof Attribute) { |
1377 count++; | 1387 count++; |
1378 if (filters.size() > count) | 1388 if (filters.size() > count) |
1379 hql += " OR "; | 1389 hql += " OR "; |
1380 } | 1390 } |
1381 | 1391 |
1382 /* ROC: led to hibernate errors | 1392 /* ROC: led to hibernate errors */ |
1383 * hql += " ) group by att.sourceId order by ent.ownValue"; | 1393 hql += " ) group by att.sourceId order by ent.ownValue"; |
1384 */ | 1394 // hql += " ) order by ent.ownValue"; |
1385 hql += " ) order by ent.ownValue"; | |
1386 | 1395 |
1387 Query query = session.createQuery(hql); | 1396 Query query = session.createQuery(hql); |
1388 if (maxResult > 0) | 1397 if (maxResult > 0) |
1389 query.setMaxResults(maxResult); | 1398 query.setMaxResults(maxResult); |
1390 query.setString("systemStatus", Node.SYS_STATUS_CURRENT_VERSION); | 1399 query.setString("systemStatus", Node.SYS_STATUS_CURRENT_VERSION); |