Skip to content

Commit 7accfc2

Browse files
committed
Fix of #564 - correct removal of unused positions, fixed tests
1 parent 7737dca commit 7accfc2

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

commons-app/src/main/java/cz/cuni/mff/xrg/odcs/commons/app/pipeline/graph/Node.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class Node implements DataObject {
5050
@JoinColumn(name = "instance_id", unique = true, nullable = false)
5151
private DPUInstanceRecord dpuInstance;
5252

53-
@OneToOne(optional = false, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
53+
@OneToOne(optional = false, cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
5454
@JoinColumn(name = "position_id", unique = true)
5555
private Position position;
5656

commons-app/src/test/java/cz/cuni/mff/xrg/odcs/commons/app/constraints/DatabaseConstraintsTest.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -464,29 +464,30 @@ Object createReferencedInstance(EntityManager em) {
464464
}.ensureReferencingInstanceDelete(Node.class, DPUInstanceRecord.class);
465465
}
466466

467-
@Test
468-
public void ON_DELETE_ppl_position_DELETE_ppl_node() {
469-
new DeleteConstraintTest() {
470-
471-
@Override
472-
Object createReferencedInstance(EntityManager em) {
473-
em.getTransaction().begin();
474-
DPUInstanceRecord dpuInstance = new DPUInstanceRecord();
475-
Position position = new Position();
476-
Node node = new Node();
477-
node.setDpuInstance(dpuInstance);
478-
node.setPosition(position);
479-
480-
em.persist(dpuInstance);
481-
em.persist(position);
482-
em.persist(node);
483-
484-
em.getTransaction().commit();
485-
return position;
486-
}
487-
488-
}.ensureReferencingInstanceDelete(Node.class, Position.class);
489-
}
467+
// Note: the test is not needed, ppl_node is removed, ppl_position is dependant class
468+
// @Test
469+
// public void ON_DELETE_ppl_position_DELETE_ppl_node() {
470+
// new DeleteConstraintTest() {
471+
//
472+
// @Override
473+
// Object createReferencedInstance(EntityManager em) {
474+
// em.getTransaction().begin();
475+
// DPUInstanceRecord dpuInstance = new DPUInstanceRecord();
476+
// Position position = new Position();
477+
// Node node = new Node();
478+
// node.setDpuInstance(dpuInstance);
479+
// node.setPosition(position);
480+
//
481+
// em.persist(dpuInstance);
482+
// em.persist(position);
483+
// em.persist(node);
484+
//
485+
// em.getTransaction().commit();
486+
// return position;
487+
// }
488+
//
489+
// }.ensureReferencingInstanceDelete(Node.class, Position.class);
490+
// }
490491

491492
@Test
492493
public void ON_DELETE_ppl_graph_DELETE_ppl_edge() {

0 commit comments

Comments
 (0)