SchemaExport se = new SchemaExport(getCfg()); se.create(true,true); // here we modify the generated table in order to test SchemaUpdate Session session = openSession(); Connection conn = session.connection(); Statement stat = conn.createStatement(); stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name "); // update schema //SchemaUpdate su = new SchemaUpdate(getCfg()); //su.execute(true,true); try { SchemaValidator sv = new SchemaValidator(getCfg()); sv.validate(); fail("should fail since we mutated the current schema."); } catch(HibernateException he) { } // it's time to clean our database se.drop(true,true); // then the schemas and false table. stat.execute("DROP TABLE \"SA\".\"Team\" "); stat.execute(" DROP SCHEMA sa "); stat.execute("DROP SCHEMA sb "); stat.close(); session.close();
SchemaExport se = new SchemaExport(getCfg()); se.create(true,true); // here we modify the generated table in order to test SchemaUpdate Session session = openSession(); Connection conn = session.connection(); Statement stat = conn.createStatement(); stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname "); // update schema //SchemaUpdate su = new SchemaUpdate(getCfg()); //su.execute(true,true); try { SchemaValidator sv = new SchemaValidator(getCfg()); sv.validate(); fail("should fail since we mutated the current schema."); } catch(HibernateException he) { } // it's time to clean our database se.drop(true,true); // then the schemas and false table. stat.execute("DROP TABLE \"SA\".\"Team\" "); stat.execute(" DROP SCHEMA sa "); stat.execute("DROP SCHEMA sb "); stat.close(); session.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
Method name: void testFailingQuoteValidation() Method name: void testFailingNonQuoteValidation()
Number of AST nodes: 16 Number of AST nodes: 16
1
SchemaExport se = new SchemaExport(getCfg());
1
SchemaExport se = new SchemaExport(getCfg());
2
		se.create(true,true);
2
		se.create(true,true);
3
		
3
		
4
		// here we modify the generated table in order to test SchemaUpdate
4
		// here we modify the generated table in order to test SchemaUpdate
5
		Session session = openSession();
5
		Session session = openSession();
6
		Connection conn = session.connection();
6
		Connection conn = session.connection();
7
		Statement stat = conn.createStatement();
7
		Statement stat = conn.createStatement();
8
		stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
8
		stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
9
		
9
		
10
		// update schema
10
		// update schema
11
		//SchemaUpdate su = new SchemaUpdate(getCfg());
11
		//SchemaUpdate su = new SchemaUpdate(getCfg());
12
		//su.execute(true,true);
12
		//su.execute(true,true);
13
		
13
		
14
		try {
14
		try {
15
			SchemaValidator sv = new SchemaValidator(getCfg());
15
			SchemaValidator sv = new SchemaValidator(getCfg());
16
			sv.validate();
16
			sv.validate();
17
			fail("should fail since we mutated the current schema.");
17
			fail("should fail since we mutated the current schema.");
18
		} catch(HibernateException he) {
18
		} catch(HibernateException he) {
19
			
19
			
20
		}
20
		}
21
		
21
		
22
		// it's time to clean our database
22
		// it's time to clean our database
23
		se.drop(true,true);
23
		se.drop(true,true);
24
		
24
		
25
		// then the schemas and false table.
25
		// then the schemas and false table.
26
		stat.execute("DROP TABLE \"SA\".\"Team\" ");
26
		stat.execute("DROP TABLE \"SA\".\"Team\" ");
27
		stat.execute(" DROP SCHEMA sa ");
27
		stat.execute(" DROP SCHEMA sa ");
28
		stat.execute("DROP SCHEMA sb ");
28
		stat.execute("DROP SCHEMA sb ");
29
		stat.close();
29
		stat.close();
30
		session.close();
30
		session.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons106
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    SchemaExport se = new SchemaExport(getCfg());
    1
    SchemaExport se = new SchemaExport(getCfg());
    2
    se.create(true, true);
    2
    se.create(true, true);
    3
    Session session = openSession();
    3
    Session session = openSession();
    4
    Connection conn = session.connection();
    4
    Connection conn = session.connection();
    5
    Statement stat = conn.createStatement();
    5
    Statement stat = conn.createStatement();
    6
    stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
    6
    stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
    6
    stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
    Differences
    Expression1Expression2Difference
    "ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ""ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname "LITERAL_VALUE_MISMATCH
    6
    stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
    7
    try
    7
    try
    8
    SchemaValidator sv = new SchemaValidator(getCfg());
    8
    SchemaValidator sv = new SchemaValidator(getCfg());
    9
    sv.validate();
    9
    sv.validate();
    10
    fail("should fail since we mutated the current schema.");
    10
    fail("should fail since we mutated the current schema.");
    11
    se.drop(true, true);
    11
    se.drop(true, true);
    12
    stat.execute("DROP TABLE \"SA\".\"Team\" ");
    12
    stat.execute("DROP TABLE \"SA\".\"Team\" ");
    13
    stat.execute(" DROP SCHEMA sa ");
    13
    stat.execute(" DROP SCHEMA sa ");
    14
    stat.execute("DROP SCHEMA sb ");
    14
    stat.execute("DROP SCHEMA sb ");
    15
    stat.close();
    15
    stat.close();
    16
    session.close();
    16
    session.close();
    Precondition Violations (0)
    Row Violation