File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java | |||
Method name: void testOrphanDeleteAfterLock()
|
Method name: void testOrphanDeleteOnSaveOrUpdate()
|
|||
Number of AST nodes: 24 | Number of AST nodes: 24 | |||
1 | Session session = openSession();↵ | 1 | Session session = openSession();↵ | |
2 | Transaction t = session.beginTransaction();↵ | 2 | Transaction t = session.beginTransaction();↵ | |
3 | Product prod = new Product( "Widget" );↵ | 3 | Product prod = new Product( "Widget" );↵ | |
4 | Part part = new Part( "Widge", "part if a Widget" );↵ | 4 | Part part = new Part( "Widge", "part if a Widget" );↵ | |
5 | MapKey mapKey = new MapKey( "Top" );↵ | 5 | MapKey mapKey = new MapKey( "Top" );↵ | |
6 | prod.getParts().put( mapKey, part );↵ | 6 | prod.getParts().put( mapKey, part );↵ | |
7 | Part part2 = new Part( "Get", "another part if a Widget" );↵ | 7 | Part part2 = new Part( "Get", "another part if a Widget" );↵ | |
8 | prod.getParts().put( new MapKey( "Bottom" ),part2 );↵ | 8 | prod.getParts().put( new MapKey( "Bottom" ), part2 );↵ | |
9 | session.persist( prod );↵ | 9 | session.persist( prod );↵ | |
10 | t.commit();↵ | 10 | t.commit();↵ | |
11 | session.close();↵ | 11 | session.close();↵ | |
12 | prod.getParts().remove( mapKey );↵ | |||
12 | session = openSession();↵ | 13 | session = openSession();↵ | |
13 | t = session.beginTransaction();↵ | 14 | t = session.beginTransaction();↵ | |
14 | session.lock(prod, LockMode.READ);↵ | 15 | session.↵ | |
15 | prod.getParts().remove(mapKey);↵ | 16 | saveOrUpdate(prod);↵ | |
16 | t.commit();↵ | 17 | t.commit();↵ | |
17 | session.close();↵ | 18 | session.close();↵ | |
18 | session = openSession();↵ | 19 | session = openSession();↵ | |
19 | t = session.beginTransaction();↵ | 20 | t = session.beginTransaction();↵ | |
20 | assertNull( session.get(Part.class, "Widge") );↵ | 21 | assertNull( session.get(Part.class, "Widge") );↵ | |
21 | assertNotNull( session.get(Part.class, "Get") );↵ | 22 | assertNotNull( session.get(Part.class, "Get") );↵ | |
22 | session.delete( session.get(Product.class, "Widget") );↵ | 23 | session.delete( session.get(Product.class, "Widget") );↵ | |
23 | t.commit();↵ | 24 | t.commit();↵ | |
24 | session.close(); | 25 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 140 |
Number of mapped statements | 24 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session session = openSession(); | 1 | Session session = openSession(); | ||||||||||||||||||||||
2 | Transaction t = session.beginTransaction(); | 2 | Transaction t = session.beginTransaction(); | ||||||||||||||||||||||
3 | Product prod = new Product("Widget"); | 3 | Product prod = new Product("Widget"); | ||||||||||||||||||||||
4 | Part part = new Part("Widge", "part if a Widget"); | 4 | Part part = new Part("Widge", "part if a Widget"); | ||||||||||||||||||||||
5 | MapKey mapKey = new MapKey("Top"); | 5 | MapKey mapKey = new MapKey("Top"); | ||||||||||||||||||||||
6 | prod.getParts().put(mapKey, part); | 6 | prod.getParts().put(mapKey, part); | ||||||||||||||||||||||
7 | Part part2 = new Part("Get", "another part if a Widget"); | 7 | Part part2 = new Part("Get", "another part if a Widget"); | ||||||||||||||||||||||
8 | prod.getParts().put(new MapKey("Bottom"), part2); | 8 | prod.getParts().put(new MapKey("Bottom"), part2); | ||||||||||||||||||||||
9 | session.persist(prod); | 9 | session.persist(prod); | ||||||||||||||||||||||
10 | t.commit(); | 10 | t.commit(); | ||||||||||||||||||||||
11 | session.close(); | 11 | session.close(); | ||||||||||||||||||||||
12 | session = openSession(); | 13 | session = openSession(); | ||||||||||||||||||||||
13 | t = session.beginTransaction(); | 14 | t = session.beginTransaction(); | ||||||||||||||||||||||
14 | session.lock(prod, LockMode.READ); |
| 15 | session.saveOrUpdate(prod); | |||||||||||||||||||||
15 | prod.getParts().remove(mapKey); | 12 | prod.getParts().remove(mapKey); | ||||||||||||||||||||||
16 | t.commit(); | 16 | t.commit(); | ||||||||||||||||||||||
17 | session.close(); | 17 | session.close(); | ||||||||||||||||||||||
18 | session = openSession(); | 18 | session = openSession(); | ||||||||||||||||||||||
19 | t = session.beginTransaction(); | 19 | t = session.beginTransaction(); | ||||||||||||||||||||||
20 | assertNull(session.get(Part.class, "Widge")); | 20 | assertNull(session.get(Part.class, "Widge")); | ||||||||||||||||||||||
21 | assertNotNull(session.get(Part.class, "Get")); | 21 | assertNotNull(session.get(Part.class, "Get")); | ||||||||||||||||||||||
22 | session.delete(session.get(Product.class, "Widget")); | 22 | session.delete(session.get(Product.class, "Widget")); | ||||||||||||||||||||||
23 | t.commit(); | 23 | t.commit(); | ||||||||||||||||||||||
24 | session.close(); | 24 | session.close(); |
Row | Violation |
---|---|
1 | Expression session.lock(prod,LockMode.READ) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression session.saveOrUpdate(prod) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression session.lock(prod,LockMode.READ) is a void method call, and thus it cannot be parameterized |
4 | Expression session.saveOrUpdate(prod) is a void method call, and thus it cannot be parameterized |
5 | Expression session.lock(prod,LockMode.READ) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression session.saveOrUpdate(prod) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression session.lock(prod,LockMode.READ) is a void method call, and thus it cannot be parameterized |
8 | Expression session.saveOrUpdate(prod) is a void method call, and thus it cannot be parameterized |