File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/typedonetoone/TypedOneToOneTest.java | |||
Method name: void testSerializableType()
|
Method name: void testCreateQueryNull()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 17 | |||
1 | Session s = openSession();↵ | |||
2 | Vetoer v = new Vetoer();↵ | 1 | Customer cust = new Customer();↵ | |
3 | v.setStrings( new String[] { "foo", "bar", "baz" } );↵ | 2 | ↵ | |
4 | s.save(v); Serializable id = s.save(v);↵ | |||
5 | v.getStrings()[1] = "osama";↵ | |||
6 | s.flush();↵ | |||
7 | s.connection()↵ | 3 | cust.setCustomerId("xyz123");↵ | |
4 | cust.setName("Matt");↵ | |||
5 | ↵ | |||
6 | Session s = openSession();↵ | |||
7 | Transaction t = s.beginTransaction();↵ | |||
8 | s.persist(cust);↵ | |||
8 | .commit();↵ | 9 | t.commit();↵ | |
9 | s.close();↵ | 10 | s.close();↵ | |
10 | ↵ | 11 | ↵ | |
11 | s = openSession();↵ | 12 | s = openSession();↵ | |
12 | v = (Vetoer) s.load(Ve↵ | 13 | t = s.beginTransaction();↵ | |
13 | toer.class, id);↵ | 14 | List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customer↵ | |
14 | assertTrue( "serializable type", v.getStrings()[1].equals("osama") );↵ | |||
15 | s.delete(v); s.delete(v);↵ | |||
16 | s.flush();↵ | |||
17 | s.connection()↵ | 15 | Id='xyz123'").list();↵ | |
16 | //List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list();↵ | |||
17 | cust = (Customer) results.get(0);↵ | |||
18 | assertNull( cust.getShippingAddress() );↵ | |||
19 | assertNull( cust.getBillingAddress() );↵ | |||
20 | s.delete(cust);↵ | |||
18 | .commit();↵ | 21 | t.commit();↵ | |
19 | s.close(); | 22 |
| |
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 | 229 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 11 |
Number of unmapped statements in the second code fragment | 11 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Customer cust = new Customer(); | ||||||||||||||||||||||
1 | Session s = openSession(); | | ||||||||||||||||||||||
| 2 | cust.setCustomerId("xyz123"); | ||||||||||||||||||||||
2 | Vetoer v = new Vetoer(); | | ||||||||||||||||||||||
| 3 | cust.setName("Matt"); | ||||||||||||||||||||||
3 | v.setStrings(new String[] {"foo", "bar", "baz"}); | | ||||||||||||||||||||||
| 4 | Session s = openSession(); | ||||||||||||||||||||||
4 | s.save(v); | | ||||||||||||||||||||||
| 5 | Transaction t = s.beginTransaction(); | ||||||||||||||||||||||
5 | Serializable id = s.save(v); | | ||||||||||||||||||||||
| 6 | s.persist(cust); | ||||||||||||||||||||||
6 | v.getStrings()[1] = "osama"; | | ||||||||||||||||||||||
| 7 | t.commit(); | ||||||||||||||||||||||
|
| 9 | s = openSession(); | |||||||||||||||||||||
| 10 | t = 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); | ||||||||||||||||||||||
7 | s.flush(); |
| 14 | assertNull(cust.getBillingAddress()); | ||||||||||||||||||||
8 | s.connection().commit(); |
| 13 | assertNull(cust.getShippingAddress()); | ||||||||||||||||||||
9 | s.close(); |
| 8 | s.close(); | ||||||||||||||||||||
10 | s = openSession(); |
| | |||||||||||||||||||||
11 | v = (Vetoer)s.load(Vetoer.class, id); | | ||||||||||||||||||||||
12 | assertTrue("serializable type", v.getStrings()[1].equals("osama")); |
| 16 | t.commit(); | ||||||||||||||||||||
13 | s.delete(v); |
| 15 | s.delete(cust); | ||||||||||||||||||||
14 | s.delete(v); | | ||||||||||||||||||||||
15 | s.flush(); | | ||||||||||||||||||||||
16 | s.connection().commit(); | | ||||||||||||||||||||||
17 | s.close(); |
| 17 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
3 | Expression assertNull(cust.getBillingAddress()) is a void method call, and thus it cannot be parameterized |
4 | Expression s.flush() is a void method call, and thus it cannot be parameterized |
5 | Expression assertNull(cust.getBillingAddress()) is a void method call, and thus it cannot be parameterized |
6 | Expression s.connection().commit() is a void method call, and thus it cannot be parameterized |
7 | Expression assertNull(cust.getShippingAddress()) is a void method call, and thus it cannot be parameterized |
8 | Expression s.connection().commit() is a void method call, and thus it cannot be parameterized |
9 | Expression assertNull(cust.getShippingAddress()) is a void method call, and thus it cannot be parameterized |
10 | Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s |
11 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Expression assertTrue("serializable type",v.getStrings()[1].equals("osama")) is a void method call, and thus it cannot be parameterized |
13 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
14 | Expression assertTrue("serializable type",v.getStrings()[1].equals("osama")) is a void method call, and thus it cannot be parameterized |
15 | Expression t.commit() is a void method call, and thus it cannot be parameterized |
16 | Type org.hibernate.test.legacy.Vetoer of variable v does not match with type org.hibernate.test.typedonetoone.Customer of variable cust |
17 | Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s |
18 | Type org.hibernate.classic.Session of variable s does not match with type org.hibernate.Session of variable s |