File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java | |||
Method name: void testPersistThenMergeInSameTxnWithVersion()
|
Method name: void testPersistThenMergeInSameTxnWithTimestamp()
|
|||
Number of AST nodes: 11 | Number of AST nodes: 11 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction tx = s.beginTransaction();↵ | 2 | Transaction tx = s.beginTransaction();↵ | |
3 | VersionedEntity entity = new VersionedEntity( "test", "test" );↵ | 3 | TimestampedEntity entity = new TimestampedEntity( "test", "test" );↵ | |
4 | s.persist( entity );↵ | 4 | s.persist( entity );↵ | |
5 | s.merge( new VersionedEntity( "test", "test-2" ) );↵ | 5 | s.merge( new TimestampedEntity( "test", "test-2" ) );↵ | |
6 | try {↵ | 6 | try {↵ | |
7 | // control operation...↵ | 7 | // control operation...↵ | |
8 | s.saveOrUpdate( new VersionedEntity( "test", "test-3" ) );↵ | 8 | s.saveOrUpdate( new TimestampedEntity( "test", "test-3" ) );↵ | |
9 | fail( "saveOrUpdate() should fail here" );↵ | 9 | fail( "saveOrUpdate() should fail here" );↵ | |
10 | }↵ | 10 | }↵ | |
11 | catch( NonUniqueObjectException expected ) {↵ | 11 | catch( NonUniqueObjectException expected ) {↵ | |
12 | // expected behavior↵ | 12 | // expected behavior↵ | |
13 | }↵ | 13 | }↵ | |
14 | tx.commit();↵ | 14 | tx.commit();↵ | |
15 | s.close();↵ | 15 | s.close();↵ | |
16 | cleanup(); | 16 |
| |
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.1 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 51 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 2.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | ||||||||||||
2 | Transaction tx = s.beginTransaction(); | 2 | Transaction tx = s.beginTransaction(); | ||||||||||||
| 3 | TimestampedEntity entity = new TimestampedEntity("test", "test"); | |||||||||||||
3 | VersionedEntity entity = new VersionedEntity("test", "test"); | | |||||||||||||
4 | s.persist(entity); |
| 4 | s.persist(entity); | |||||||||||
5 | s.merge(new VersionedEntity("test", "test-2")); |
| 5 | s.merge(new TimestampedEntity("test", "test-2")); | |||||||||||
6 | try | 6 | try | ||||||||||||
7 | s.saveOrUpdate(new VersionedEntity("test", "test-3")); |
| 7 | s.saveOrUpdate(new TimestampedEntity("test", "test-3")); | |||||||||||
8 | fail("saveOrUpdate() should fail here"); | 8 | fail("saveOrUpdate() should fail here"); | ||||||||||||
9 | tx.commit(); | 9 | tx.commit(); | ||||||||||||
10 | s.close(); | 10 | s.close(); | ||||||||||||
11 | cleanup(); | 11 | cleanup(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.ops.VersionedEntity of variable entity does not match with type org.hibernate.test.ops.TimestampedEntity of variable entity |
2 | Type org.hibernate.test.ops.VersionedEntity of variable new VersionedEntity("test","test-2") does not match with type org.hibernate.test.ops.TimestampedEntity of variable new TimestampedEntity("test","test-2") |
3 | Type org.hibernate.test.ops.VersionedEntity of variable new VersionedEntity("test","test-3") does not match with type org.hibernate.test.ops.TimestampedEntity of variable new TimestampedEntity("test","test-3") |