File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java | |||
Method name: void testManyToManyFilterOnCriteria()
|
Method name: void testManyToManyFilterOnQuery()
|
|||
Number of AST nodes: 9 | Number of AST nodes: 11 | |||
1 | TestData testData = new TestData();↵ | 1 | TestData testData = new TestData();↵ | |
2 | testData.prepare();↵ | 2 | testData.prepare();↵ | |
3 | Session session = openSession();↵ | 3 | Session session = openSession();↵ | |
4 | session.enableFilter( "effectiveDate" ).setParameter( "asOfDate", new Date() );↵ | 4 | session.enableFilter( "effectiveDate" ).setParameter( "asOfDate", new Date() );↵ | |
5 | Product prod = ( Product ) session.createCriteria( Product.class )↵ | 5 | List result = session.create↵ | |
6 | .setResultTransformer( new DistinctRootEntityResultTransformer() )↵ | |||
7 | .add( Restrictions.eq( "id", testData.prod1Id ↵ | 6 | Query( "from Product p inner join fetch p.categories" ).list();↵ | |
8 | ) )↵ | 7 | assertTrue( "No products returned from HQL many-to-many filter case", !result.isEmpty() );↵ | |
9 | .uniqueResult();↵ | 8 | Product prod = ( Product ) result.get( 0 );↵ | |
10 | assertNotNull( prod );↵ | 9 | assertNotNull( prod );↵ | |
11 | assertEquals( "Incorrect Product.categories count for filter", 1, prod.getCategories().size() );↵ | 10 | assertEquals( "Incorrect Product.categories count for filter with HQL", 1, prod.getCategories().size() );↵ | |
12 | session.close();↵ | 11 | session.close();↵ | |
13 | testData.release(); | 12 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 67 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | TestData testData = new TestData(); | 1 | TestData testData = new TestData(); | |||||||||||
2 | testData.prepare(); | 2 | testData.prepare(); | |||||||||||
3 | Session session = openSession(); | 3 | Session session = openSession(); | |||||||||||
4 | session.enableFilter("effectiveDate").setParameter("asOfDate", new Date()); | 4 | session.enableFilter("effectiveDate").setParameter("asOfDate", new Date()); | |||||||||||
| 5 | List result = session.createQuery("from Product p inner join fetch p.categories").list(); | ||||||||||||
5 | Product prod = (Product)session.createCriteria(Product.class).setResultTransformer(new DistinctRootEntityResultTransformer()).add(Restrictions.eq("id", testData.prod1Id)).uniqueResult(); |
| | |||||||||||
| 6 | assertTrue("No products returned from HQL many-to-many filter case", !result.isEmpty()); | ||||||||||||
| 7 | Product prod = (Product)result.get(0); | ||||||||||||
6 | assertNotNull(prod); | 8 | assertNotNull(prod); | |||||||||||
7 | assertEquals("Incorrect Product.categories count for filter", 1, prod.getCategories().size()); |
| 9 | assertEquals("Incorrect Product.categories count for filter with HQL", 1, prod.getCategories().size()); | ||||||||||
8 | session.close(); | 10 | session.close(); | |||||||||||
9 | testData.release(); | 11 | testData.release(); |
Row | Violation |
---|---|
1 | Unmatched statement Product prod=(Product)session.createCriteria(Product.class).setResultTransformer(new DistinctRootEntityResultTransformer()).add(Restrictions.eq("id",testData.prod1Id)).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Clone fragment #1 returns variables testData, session , while Clone fragment #2 returns variables session |