File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/typedonetoone/TypedOneToOneTest.java | |||
Method name: void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected()
|
Method name: void testCreateQueryNull()
|
|||
Number of AST nodes: 15 | Number of AST nodes: 17 | |||
1 | Session s = openSession();↵ | |||
2 | s.beginTransaction();↵ | |||
3 | Customer cust = new Customer( "Acme, Inc." ); ↵ | 1 | Customer cust = new Customer();↵ | |
4 | Order order = new Order( new Order.Id( cust, 1 ) ); ↵ | 2 | cust.setCustomerId("xyz123");↵ | |
5 | cust.getOrders().add( order );↵ | 3 | cust.set↵ | |
6 | s.save( cust ↵ | 4 | Name("Matt");↵ | |
5 | ↵ | |||
7 | ); ↵ | 6 | Session s = openSession();↵ | |
8 | s.getTransaction()↵ | 7 | Transaction t = s.beginTransaction();↵ | |
8 | s.persist(cust);↵ | |||
9 | .commit(); ↵ | 9 | t.commit();↵ | |
10 | s.close();↵ | 10 | s.close();↵ | |
11 | ↵ | |||
11 | ↵ | |||
12 | s = openSession(); ↵ | 12 | s = openSession();↵ | |
13 | s.beginTransaction(); ↵ | 13 | t = s.beginTransaction();↵ | |
14 | try {↵ | 14 | ↵ | |
15 | cust = ( Customer ) s.get( Customer.class, cust.getId() ); ↵ | 15 | List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();↵ | |
16 | }↵ | 16 | ↵ | |
17 | catch( OverflowCondition overflow ) {↵ | |||
18 | fail( "get()/load()↵ | 17 | //List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list();↵ | |
18 | cust = (Customer) results.get(0);↵ | |||
19 | caused overflow condition" );↵ | 19 | assertNull( cus↵ | |
20 | } ↵ | 20 | t.getShippingAddress() );↵ | |
21 | assertNull( cust.getBillingAddress() );↵ | |||
21 | s.delete( cust ); ↵ | 22 | s.delete(cust);↵ | |
22 | s.getTransaction().commit(); ↵ | 23 | t.commit();↵ | |
23 | s.close(); | 24 |
| |
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 in different classes having the same super class |
Number of node comparisons | 169 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 8 |
Number of unmapped statements in the second code fragment | 12 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Customer cust = new Customer(); | |||||||||||||
|
| 2 | cust.setCustomerId("xyz123"); | ||||||||||||
1 | Session s = openSession(); | 4 | Session s = openSession(); | ||||||||||||
2 | s.beginTransaction(); |
| | ||||||||||||
|
| 3 | cust.setName("Matt"); | ||||||||||||
3 | Customer cust = new Customer("Acme, Inc."); |
| | ||||||||||||
4 | Order order = new Order(new Order.Id(cust, 1)); |
| | ||||||||||||
|
| 5 | Transaction t = s.beginTransaction(); | ||||||||||||
5 | cust.getOrders().add(order); | | |||||||||||||
|
| 6 | s.persist(cust); | ||||||||||||
6 | s.save(cust); |
| | ||||||||||||
|
| 7 | t.commit(); | ||||||||||||
7 | s.getTransaction().commit(); |
| | ||||||||||||
8 | s.close(); | 8 | s.close(); | ||||||||||||
9 | s = openSession(); | 9 | s = openSession(); | ||||||||||||
|
| 10 | t = s.beginTransaction(); | ||||||||||||
10 | s.beginTransaction(); |
| | ||||||||||||
|
| 11 | List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); | ||||||||||||
| 12 | cust = (Customer)results.get(0); | |||||||||||||
| 13 | assertNull(cust.getShippingAddress()); | |||||||||||||
| 14 | assertNull(cust.getBillingAddress()); | |||||||||||||
13 | s.delete(cust); |
| 15 | s.delete(cust); | |||||||||||
14 | s.getTransaction().commit(); |
| | ||||||||||||
|
| 16 | t.commit(); | ||||||||||||
15 | s.close(); | 17 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement cust.setCustomerId("xyz123"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement cust.setName("Matt"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement Customer cust=new Customer("Acme, Inc."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement Order order=new Order(new Order.Id(cust,1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement s.persist(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement s.save(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
10 | Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Unmatched statement List results=s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust |
15 | Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |