try { s.getTransaction().commit(); fail( "expecting TransientObjectException on flush" ); } catch( TransientObjectException e ) { // expected result log.trace( "handled expected exception : " + e ); s.getTransaction().rollback(); } finally { s.close(); }
try { // The new membership is transient (it has a null surrogate ID), so // Hibernate assumes that it should be added to the collection. // Inserts are done before deletes, so a ConstraintViolationException // will be thrown on the insert because the unique constraint on the // user and group IDs in the join table is violated. See HHH-2801. s.merge( getUser() ); s.getTransaction().commit(); fail( "should have failed because inserts are before deletes"); } catch( ConstraintViolationException ex ) { // expected s.getTransaction().rollback(); } finally { s.close(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/jpa/cascade/CascadeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/manytomanyassociationclass/surrogateid/generated/ManyToManyAssociationClassGeneratedIdTest.java
Method name: void testOneToOnePropertyRefGeneratedIds() Method name: void testRemoveAndAddEqualElementNonKeyModified()
Number of AST nodes: 3 Number of AST nodes: 4
1
try {
1
try {
2
				s.getTransaction().commit();
2
			
3
				fail( "expecting TransientObjectException on flush" );
4
			}
5
			catch( TransientObjectException e ) {
3
// The new membership is transient (it has a null surrogate ID), so
4
			// Hibernate assumes that it should be added to the collection.
5
			// Inserts are done before deletes, so a ConstraintViolationException
6
			// will be thrown on the insert because the unique constraint on the
6
				// expected result
7
			// 
7
				log.trace( "handled expected exception : " + e );
8
	
8
user and group IDs in the join table is violated. See HHH-2801.
9
			s.merge( getUser() );
10
			s.getTransaction().commit();
11
			fail( "should have failed because inserts are before deletes");
12
		}
13
		catch( ConstraintViolationException ex ) {
14
			// expected
9
			s.getTransaction().rollback();
15
			s.getTransaction().rollback();
10
			}
16
		}
11
			finally {
17
		finally {
12
				s.close();
18
			s.close();
13
			}
19
		}
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes having the same super class
Number of node comparisons1