File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/generatedkeys/identity/IdentityGeneratedKeysTest.java | |||
Method name: void testPersistOutsideTransactionCascadedToManyToOne()
|
Method name: void testPersistOutsideTransactionCascadedFromManyToOne()
|
|||
Number of AST nodes: 16 | Number of AST nodes: 17 | |||
1 | long initialInsertCount = sfi().getStatistics().getEntityInsertCount();↵ | 1 | long initialInsertCount = sfi().getStatistics().getEntityInsertCount();↵ | |
2 | Session s = openSession();↵ | 2 | Session s = openSession();↵ | |
3 | MyEntity myEntity = new MyEntity( "test-persist");↵ | 3 | MyEntity myEntity2 = new MyEntity( "test-persist-2");↵ | |
4 | myEntity.setSibling( new MySibling( "test-persist-sibling-out" ) );↵ | 4 | MySibling sibling = new MySibling( "test-persist-sibling-in" );↵ | |
5 | s.persist( myEntity↵ | 5 | sibling.setEntity( myEntity2 );↵ | |
6 | );↵ | 6 | s.persist( sibling );↵ | |
7 | assertEquals( "persist on identity column not delayed", initialInsertCount, sfi().getStatistics().getEntityInsertCount() );↵ | 7 | assertEquals( "persist on identity column not delayed", initialInsertCount, sfi().getStatistics().getEntityInsertCount() );↵ | |
8 | assertNull( myEntity.getId() );↵ | 8 | assertNull( myEntity2.getId() );↵ | |
9 | s.flush();↵ | 9 | s.flush();↵ | |
10 | assertEquals( "delayed persist insert not executed on flush", initialInsertCount + 2, sfi().getStatistics().getEntityInsertCount() );↵ | 10 | assertEquals( "delayed persist insert not executed on flush", initialInsertCount + 2, sfi().getStatistics().getEntityInsertCount() );↵ | |
11 | s.close();↵ | 11 | s.close();↵ | |
12 | s = openSession();↵ | 12 | s = openSession();↵ | |
13 | s.beginTransaction();↵ | 13 | s.beginTransaction();↵ | |
14 | s.createQuery( "delete MyEntity" ).executeUpdate();↵ | 14 | s.createQuery( "delete MySibling" ).executeUpdate();↵ | |
15 | s.createQuery( "delete MySibling" ).executeUpdate();↵ | 15 | s.createQuery( "delete MyEntity" ).executeUpdate();↵ | |
16 | s.getTransaction().commit();↵ | 16 | s.getTransaction().commit();↵ | |
17 | s.close(); | 17 |
| |
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 declared in the same class |
Number of node comparisons | 190 |
Number of mapped statements | 15 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | long initialInsertCount = sfi().getStatistics().getEntityInsertCount(); | 1 | long initialInsertCount = sfi().getStatistics().getEntityInsertCount(); | |||||||||||||||||
2 | Session s = openSession(); | 2 | Session s = openSession(); | |||||||||||||||||
3 | MyEntity myEntity = new MyEntity("test-persist"); |
| 3 | MyEntity myEntity2 = new MyEntity("test-persist-2"); | ||||||||||||||||
|
| 4 | MySibling sibling = new MySibling("test-persist-sibling-in"); | |||||||||||||||||
4 | myEntity.setSibling(new MySibling("test-persist-sibling-out")); |
| | |||||||||||||||||
|
| 5 | sibling.setEntity(myEntity2); | |||||||||||||||||
5 | s.persist(myEntity); |
| 6 | s.persist(sibling); | ||||||||||||||||
6 | assertEquals("persist on identity column not delayed", initialInsertCount, sfi().getStatistics().getEntityInsertCount()); | 7 | assertEquals("persist on identity column not delayed", initialInsertCount, sfi().getStatistics().getEntityInsertCount()); | |||||||||||||||||
7 | assertNull(myEntity.getId()); |
| 8 | assertNull(myEntity2.getId()); | ||||||||||||||||
8 | s.flush(); | 9 | s.flush(); | |||||||||||||||||
9 | assertEquals("delayed persist insert not executed on flush", initialInsertCount + 2, sfi().getStatistics().getEntityInsertCount()); | 10 | assertEquals("delayed persist insert not executed on flush", initialInsertCount + 2, sfi().getStatistics().getEntityInsertCount()); | |||||||||||||||||
10 | s.close(); | 11 | s.close(); | |||||||||||||||||
11 | s = openSession(); | 12 | s = openSession(); | |||||||||||||||||
12 | s.beginTransaction(); | 13 | s.beginTransaction(); | |||||||||||||||||
13 | s.createQuery("delete MyEntity").executeUpdate(); | 15 | s.createQuery("delete MyEntity").executeUpdate(); | |||||||||||||||||
14 | s.createQuery("delete MySibling").executeUpdate(); | 14 | s.createQuery("delete MySibling").executeUpdate(); | |||||||||||||||||
15 | s.getTransaction().commit(); | 16 | s.getTransaction().commit(); | |||||||||||||||||
16 | s.close(); | 17 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement MySibling sibling=new MySibling("test-persist-sibling-in"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement myEntity.setSibling(new MySibling("test-persist-sibling-out")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement sibling.setEntity(myEntity2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Expression myEntity cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression sibling cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Type org.hibernate.test.generatedkeys.identity.MyEntity of variable myEntity does not match with type org.hibernate.test.generatedkeys.identity.MySibling of variable sibling |
7 | Expression myEntity cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression myEntity2 cannot be parameterized, because it has dependencies to/from statements that will be extracted |