String functionName = locateAppropriateDialectFunctionNameForAliasTest(); if (functionName == null) { log.info("Dialect does not list any no-arg functions"); return; } log.info("Using function named [" + functionName + "] for 'function as alias' test"); String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10"; Session s = openSession(); Transaction t = s.beginTransaction(); Simple simple = new Simple(); simple.setName("Simple 1"); s.save( simple, new Long(10) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); List result = s.find(query); assertTrue( result.size() == 1 ); assertTrue(result.get(0) instanceof Simple); s.delete( result.get(0) ); t.commit(); s.close();
String functionName = locateAppropriateDialectFunctionNameForAliasTest(); if (functionName == null) { log.info("Dialect does not list any no-arg functions"); return; } log.info("Using function named [" + functionName + "] for 'function as alias' test"); String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10"; Session s = openSession(); Transaction t = s.beginTransaction(); Simple simple = new Simple(); simple.setName("Simple 1"); s.save( simple, new Long(10) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); List result = s.find(query); assertTrue( result.size() == 1 ); assertTrue(result.get(0) instanceof Simple); s.delete( result.get(0) ); t.commit(); 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/dialect/functional/cache/SQLFunctionsInterSystemsTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
Method name: void testSqlFunctionAsAlias() Method name: void testSqlFunctionAsAlias()
Number of AST nodes: 21 Number of AST nodes: 21
1
String functionName = locateAppropriateDialectFunctionNameForAliasTest();
1
String functionName = locateAppropriateDialectFunctionNameForAliasTest();
2
		if (functionName == null) {
2
		if (functionName == null) {
3
			log.info("Dialect does not list any no-arg functions");
3
			log.info("Dialect does not list any no-arg functions");
4
			return;
4
			return;
5
		}
5
		}
6

7
		log.info("Using function named [" + functionName + "] for 'function as alias' test");
6
		log.info("Using function named [" + functionName + "] for 'function as alias' test");
8
		String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10";
7
		String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10";
9

10
		Session s = openSession();
8
		Session s = openSession();
11
		Transaction t = s.beginTransaction();
9
		Transaction t = s.beginTransaction();
12
		Simple simple = new Simple();
10
		Simple simple = new Simple();
13
		simple.setName("Simple 1");
11
		simple.setName("Simple 1");
14
		s.save( simple, new Long(10) );
12
		s.save( simple, new Long(10) );
15
		t.commit();
13
		t.commit();
16
		s.close();
14
		s.close();
17

18
		s = openSession();
15
		s = openSession();
19
		t = s.beginTransaction();
16
		t = s.beginTransaction();
20
		List result = s.find(query);
17
		List result = s.find(query);
21
		assertTrue( result.size() == 1 );
18
		assertTrue( result.size() == 1 );
22
		assertTrue(result.get(0) instanceof Simple);
19
		assertTrue(result.get(0) instanceof Simple);
23
		s.delete( result.get(0) );
20
		s.delete( result.get(0) );
24
		t.commit();
21
		t.commit();
25
		s.close();
22
		s.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 in different classes having the same super class
Number of node comparisons120
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.3
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    String functionName = locateAppropriateDialectFunctionNameForAliasTest();
    1
    String functionName = locateAppropriateDialectFunctionNameForAliasTest();
    2
    if (functionName == null)
    2
    if (functionName == null)
    3
    log.info("Dialect does not list any no-arg functions");
    3
    log.info("Dialect does not list any no-arg functions");
    4
    return;
    4
    return;
    5
    log.info("Using function named [" + functionName + "] for 'function as alias' test");
    5
    log.info("Using function named [" + functionName + "] for 'function as alias' test");
    6
    String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10";
    6
    String query = "select " + functionName + " from Simple as " + functionName + " where " + functionName + ".id = 10";
    7
    Session s = openSession();
    7
    Session s = openSession();
    8
    Transaction t = s.beginTransaction();
    8
    Transaction t = s.beginTransaction();
    9
    Simple simple = new Simple();
    9
    Simple simple = new Simple();
    10
    simple.setName("Simple 1");
    10
    simple.setName("Simple 1");
    11
    s.save(simple, new Long(10));
    11
    s.save(simple, new Long(10));
    12
    t.commit();
    12
    t.commit();
    13
    s.close();
    13
    s.close();
    14
    s = openSession();
    14
    s = openSession();
    15
    t = s.beginTransaction();
    15
    t = s.beginTransaction();
    16
    List result = s.find(query);
    16
    List result = s.find(query);
    17
    assertTrue(result.size() == 1);
    17
    assertTrue(result.size() == 1);
    18
    assertTrue(result.get(0) instanceof Simple);
    18
    assertTrue(result.get(0) instanceof Simple);
    19
    s.delete(result.get(0));
    19
    s.delete(result.get(0));
    20
    t.commit();
    20
    t.commit();
    21
    s.close();
    21
    s.close();
    Precondition Violations (0)
    Row Violation