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 testOneToManyFilters()
|
Method name: void testManyToManyFilterOnCriteria()
|
|||
Number of AST nodes: 11 | Number of AST nodes: 9 | |||
1 | log.info( "Starting one-to-many collection loader filter tests." );↵ | |||
2 | TestData testData = new TestData();↵ | 1 | TestData testData = new TestData();↵ | |
3 | testData.prepare();↵ | 2 | testData.prepare();↵ | |
4 | Session session = openSession();↵ | 3 | Session session = openSession();↵ | |
5 | session.enableFilter( "seniorSalespersons" )↵ | 4 | session.enableFilter( "↵ | |
6 | .setParameter( "asOfDate", testData.lastMonth.getTime() );↵ | 5 | effectiveDate" ).setParameter( "asOfDate", ↵ | |
7 | log.info( "Performing load of Department..."↵ | 6 | new Date() );↵ | |
8 | );↵ | 7 | Product prod = ( Product ) session.createCriteria( Product.class )↵ | |
9 | Department department = ( Department ) session.load( Department.class↵ | 8 | .setResultTransformer( new DistinctRootEntityResultTransformer() )↵ | |
10 | , testData.deptId );↵ | 9 | .add( Restrictions.eq( "id", testData.prod1Id ) )↵ | |
11 | Set salespersons = department.getSalespersons();↵ | 10 | ↵ | |
12 | assertEquals( "Incorrect salesperson count", 1, salespersons↵ | 11 | .uniqueResult();↵ | |
12 | assertNotNull( prod );↵ | |||
13 | .size() );↵ | 13 | assertEquals( "Incorrect Product.categories count for filter", 1, prod.getCategories().size() );↵ | |
14 | session.close();↵ | 14 | session.close();↵ | |
15 | testData.release(); | 15 |
| |
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.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 67 |
Number of mapped statements | 7 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | log.info("Starting one-to-many collection loader filter tests."); | | |||||||||||||||||||||||
2 | TestData testData = new TestData(); | 1 | TestData testData = new TestData(); | ||||||||||||||||||||||
3 | testData.prepare(); | 2 | testData.prepare(); | ||||||||||||||||||||||
4 | Session session = openSession(); | 3 | Session session = openSession(); | ||||||||||||||||||||||
5 | session.enableFilter("seniorSalespersons").setParameter("asOfDate", testData.lastMonth.getTime()); |
| 4 | session.enableFilter("effectiveDate").setParameter("asOfDate", new Date()); | |||||||||||||||||||||
|
| 5 | Product prod = (Product)session.createCriteria(Product.class).setResultTransformer(new DistinctRootEntityResultTransformer()).add(Restrictions.eq("id", testData.prod1Id)).uniqueResult(); | ||||||||||||||||||||||
6 | log.info("Performing load of Department..."); | | |||||||||||||||||||||||
| 7 | assertEquals("Incorrect Product.categories count for filter", 1, prod.getCategories().size()); | |||||||||||||||||||||||
7 | Department department = (Department)session.load(Department.class, testData.deptId); |
| | ||||||||||||||||||||||
8 | Set salespersons = department.getSalespersons(); | | |||||||||||||||||||||||
9 | assertEquals("Incorrect salesperson count", 1, salespersons.size()); |
| 6 | assertNotNull(prod); | |||||||||||||||||||||
10 | session.close(); | 8 | session.close(); | ||||||||||||||||||||||
11 | testData.release(); | 9 | testData.release(); |
Row | Violation |
---|---|
1 | Expression testData.lastMonth.getTime() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | 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 |
3 | Unmatched statement Department department=(Department)session.load(Department.class,testData.deptId); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Expression assertEquals("Incorrect salesperson count",1,salespersons.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression assertNotNull(prod) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression assertEquals("Incorrect salesperson count",1,salespersons.size()) is a void method call, and thus it cannot be parameterized |
7 | Expression assertNotNull(prod) is a void method call, and thus it cannot be parameterized |
8 | Expression assertEquals("Incorrect salesperson count",1,salespersons.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression assertNotNull(prod) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression assertEquals("Incorrect salesperson count",1,salespersons.size()) is a void method call, and thus it cannot be parameterized |
11 | Expression assertNotNull(prod) is a void method call, and thus it cannot be parameterized |