String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";
Configuration cfg = new Configuration();
cfg.addResource( resourceName );
try {
cfg.addResource( resourceName );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "resource" );
assertEquals( inv.getPath(), resourceName );
assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
}
Session s = openSession();
Transaction tx = s.beginTransaction();
TimestampedEntity entity = new TimestampedEntity( "test", "test" );
s.persist( entity );
s.merge( new TimestampedEntity( "test", "test-2" ) );
try {
// control operation...
s.saveOrUpdate( new TimestampedEntity( "test", "test-3" ) );
fail( "saveOrUpdate() should fail here" );
}
catch( NonUniqueObjectException expected ) {
// expected behavior
}
tx.commit();
s.close();
cleanup();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java
|
Method name: void testDuplicateMapping()
|
|
Method name: void testPersistThenMergeInSameTxnWithTimestamp()
|
Number of AST nodes: 6
|
|
Number of AST nodes: 11
|
|
1 | String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";↵ | | 1 | S↵
|
2 | Configuration cfg = new Configura↵ | | 2 | ession s = openSession();↵
|
3 | tion();
↵ | | 3 | Transaction tx = s.beginTransaction();↵
|
4 | cfg.addResource( resourceName );
↵ | | 4 | TimestampedEntity entity = new TimestampedEntity( "test", "test" );↵
|
5 | try {↵ | | 5 | ↵
|
6 | cfg.addResource( resourceName );↵ | | |
|
7 | fail();↵ | | |
|
8 | }↵ | | |
|
9 | catch ( InvalidMappingException inv ) {↵ | | |
|
10 | assertEquals( inv.getType()↵ | | 6 | s.persist( entity );↵
|
| | | 7 | s.merge( new TimestampedEntity( "test", "test-2" ) );↵
|
|
| | | 8 | try {↵
|
| | | 9 | // control operation...↵
|
11 | , "resource" );↵ | | 10 | s.saveOrUpdate( new TimestampedEntity( "test", "tes↵
|
12 | assertEquals( inv.getP↵ | | 11 | t-3" ) );↵
|
13 | ath(), resourceName );
↵ | | 12 | fail( "saveOrUpdate() should fail here" );↵
|
14 | assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class ↵ | | 13 | }↵
|
| | | 14 | catch( NonUniqueObjectException expected ) {↵
|
| | | 15 | // expected behavior↵
|
| | | 16 | }↵
|
|
| | | 17 | tx.commit();↵
|
15 | );
↵ | | 18 | s.close();↵
|
|
16 | } | | 19 | cleanup();
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 0 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 25 |