File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/deletetransient/DeleteTransientEntityTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java | |||
Method name: void testTransientEntityDeletionCascadingToDetachedAssociation()
|
Method name: void testCascadeSave()
|
|||
Number of AST nodes: 20 | Number of AST nodes: 18 | |||
1 | Session s = openSession(); ↵ | 1 | Session s = openSession();↵ | |
2 | Transaction t = s.beginTransaction(); ↵ | 2 | Transaction t = s.beginTransaction();↵ | |
3 | Address address = new Address(); ↵ | 3 | Baz baz = new Baz();↵ | |
4 | address.setInfo( "123 Main St." );↵ | 4 | ↵ | |
5 | s.save( address );↵ | |||
6 | t.commit(); ↵ | 5 | List list = new ArrayList();↵ | |
7 | s.close();↵ | 6 | ↵ | |
8 | s = openSession();↵ | |||
9 | t = s.beginTransaction();↵ | |||
10 | Person p = new Person(↵ | 7 | list.add( new Fee() );↵ | |
11 | ); ↵ | 8 | list.add( new Fee() );↵ | |
12 | p.getAddresses().add( address ); ↵ | 9 | baz.setFees(list);↵ | |
13 | s.delete( p ); ↵ | 10 | s.save(baz);↵ | |
14 | t.commit(); ↵ | 11 | t.commit();↵ | |
15 | s.close();↵ | 12 | s.close();↵ | |
16 | ↵ | |||
17 | s = openSession(); ↵ | 13 | s = openSession();↵ | |
18 | t = s.beginTransaction(); ↵ | 14 | t = s.beginTransaction();↵ | |
19 | Long count = ( Long ) s.createQuery( "select count(*) from Address" ).list().get( 0 ); ↵ | 15 | baz = (Baz) s.load( Baz.class, baz.getCode() );↵ | |
20 | assertEquals( "delete not cascaded properly across transient entity", 0, count.longValue↵ | 16 | assertTrue( baz.getFees().size()==2 );↵ | |
17 | s.delete(baz);↵ | |||
21 | () ); ↵ | 18 | assertTrue( !s.iterate("from Fee fee").hasNext() );↵ | |
22 | t.commit(); ↵ | 19 | t.commit();↵ | |
23 | s.close(); | 20 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 225 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 10 |
Number of unmapped statements in the second code fragment | 8 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Session s = openSession(); | ||||||||||||||||||||||||||
1 | Session s = openSession(); | | ||||||||||||||||||||||||||
2 | Transaction t = s.beginTransaction(); |
| 2 | Transaction t = s.beginTransaction(); | ||||||||||||||||||||||||
| 3 | Baz baz = new Baz(); | ||||||||||||||||||||||||||
3 | Address address = new Address(); | | ||||||||||||||||||||||||||
| 4 | List list = new ArrayList(); | ||||||||||||||||||||||||||
4 | address.setInfo("123 Main St."); | | ||||||||||||||||||||||||||
| 5 | list.add(new Fee()); | ||||||||||||||||||||||||||
| 6 | list.add(new Fee()); | ||||||||||||||||||||||||||
5 | s.save(address); |
| 8 | s.save(baz); | ||||||||||||||||||||||||
6 | t.commit(); | 9 | t.commit(); | |||||||||||||||||||||||||
7 | s.close(); |
| 10 | s.close(); | ||||||||||||||||||||||||
8 | s = openSession(); |
| | |||||||||||||||||||||||||
|
| 11 | s = openSession(); | |||||||||||||||||||||||||
9 | t = s.beginTransaction(); |
| 12 | t = s.beginTransaction(); | ||||||||||||||||||||||||
10 | Person p = new Person(); | | ||||||||||||||||||||||||||
11 | p.getAddresses().add(address); | | ||||||||||||||||||||||||||
|
| 13 | baz = (Baz)s.load(Baz.class, baz.getCode()); | |||||||||||||||||||||||||
12 | s.delete(p); |
| 15 | s.delete(baz); | ||||||||||||||||||||||||
| 16 | assertTrue(!s.iterate("from Fee fee").hasNext()); | ||||||||||||||||||||||||||
13 | t.commit(); | 17 | t.commit(); | |||||||||||||||||||||||||
14 | s.close(); | | ||||||||||||||||||||||||||
15 | s = openSession(); |
| | |||||||||||||||||||||||||
16 | t = s.beginTransaction(); |
| | |||||||||||||||||||||||||
17 | Long count = (Long)s.createQuery("select count(*) from Address").list().get(0); | | ||||||||||||||||||||||||||
18 | assertEquals("delete not cascaded properly across transient entity", 0, count.longValue()); |
| 7 | baz.setFees(list); | ||||||||||||||||||||||||
19 | t.commit(); |
| 14 | assertTrue(baz.getFees().size() == 2); | ||||||||||||||||||||||||
20 | s.close(); |
| 18 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
2 | Type org.hibernate.test.deletetransient.Address of variable address does not match with type org.hibernate.test.legacy.Baz of variable baz |
3 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
4 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
5 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
8 | Unmatched statement baz=(Baz)s.load(Baz.class,baz.getCode()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Type org.hibernate.test.deletetransient.Person of variable p does not match with type org.hibernate.test.legacy.Baz of variable baz |
10 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |
11 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Expression assertEquals("delete not cascaded properly across transient entity",0,count.longValue()) is a void method call, and thus it cannot be parameterized |
14 | Expression baz.setFees(list) is a void method call, and thus it cannot be parameterized |
15 | Expression assertEquals("delete not cascaded properly across transient entity",0,count.longValue()) is a void method call, and thus it cannot be parameterized |
16 | Expression baz.setFees(list) is a void method call, and thus it cannot be parameterized |
17 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
20 | Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized |
21 | Expression t.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression assertTrue(baz.getFees().size() == 2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
24 | Expression assertTrue(baz.getFees().size() == 2) is a void method call, and thus it cannot be parameterized |
25 | Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s |