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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 105 |
Number of mapped statements | 21 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 38.8 |
Clone type | Type 1 |
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(); |
Row | Violation |
---|