File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/CreateTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/CreateTest.java | |||
Method name: void testCreateException()
|
Method name: void testCreateExceptionWithGeneratedId()
|
|||
Number of AST nodes: 25 | Number of AST nodes: 23 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction tx = s.beginTransaction();↵ | 2 | Transaction tx = s.beginTransaction();↵ | |
3 | Node dupe = new Node("dupe");↵ | 3 | NumberedNode dupe = new NumberedNode("dupe");↵ | |
4 | s.persist(dupe);↵ | 4 | s.persist(dupe);↵ | |
5 | s.persist(dupe);↵ | 5 | s.persist(dupe);↵ | |
6 | tx.commit();↵ | 6 | tx.commit();↵ | |
7 | s.close();↵ | 7 | s.close();↵ | |
8 | s = openSession();↵ | 8 | s = openSession();↵ | |
9 | tx = s.beginTransaction();↵ | 9 | tx = s.beginTransaction();↵ | |
10 | ↵ | 10 | try {↵ | |
11 | s.persist(dupe);↵ | 11 | s.persist(dupe);↵ | |
12 | try {↵ | 12 | ↵ | |
13 | tx.commit();↵ | |||
14 | assertFalse(true);↵ | 13 | assertFalse(true);↵ | |
15 | }↵ | 14 | }↵ | |
16 | catch (ConstraintViolationException cve) {↵ | 15 | catch (PersistentObjectException poe) {↵ | |
17 | //verify that an exception is thrown!↵ | 16 | //verify that an exception is thrown!↵ | |
18 | }↵ | 17 | }↵ | |
19 | tx.rollback();↵ | 18 | tx.rollback();↵ | |
20 | s.close();↵ | 19 | s.close();↵ | |
21 | Node nondupe = new Node("nondupe");↵ | 20 | NumberedNode nondupe = new NumberedNode("nondupe");↵ | |
22 | nondupe.addChild(dupe);↵ | 21 | nondupe.addChild(dupe);↵ | |
23 | s = openSession();↵ | 22 | s = openSession();↵ | |
24 | tx = s.beginTransaction();↵ | 23 | tx = s.beginTransaction();↵ | |
25 | ↵ | 24 | try {↵ | |
26 | s.persist(nondupe);↵ | 25 | s.persist(nondupe);↵ | |
27 | try {↵ | 26 | ↵ | |
28 | tx.commit();↵ | |||
29 | assertFalse(true);↵ | 27 | assertFalse(true);↵ | |
30 | }↵ | 28 | }↵ | |
31 | catch (ConstraintViolationException cve) {↵ | 29 | catch (PersistentObjectException poe) {↵ | |
32 | //verify that an exception is thrown!↵ | 30 | //verify that an exception is thrown!↵ | |
33 | }↵ | 31 | }↵ | |
34 | tx.rollback();↵ | 32 | tx.rollback();↵ | |
35 | s.close(); | 33 |
| |
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.4 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 103 |
Number of mapped statements | 18 |
Number of unmapped statements in the first code fragment | 7 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 9.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | |||||||||||||||||||||||
2 | Transaction tx = s.beginTransaction(); | 2 | Transaction tx = s.beginTransaction(); | |||||||||||||||||||||||
| 3 | NumberedNode dupe = new NumberedNode("dupe"); | ||||||||||||||||||||||||
3 | Node dupe = new Node("dupe"); | | ||||||||||||||||||||||||
4 | s.persist(dupe); |
| 4 | s.persist(dupe); | ||||||||||||||||||||||
5 | s.persist(dupe); |
| 5 | s.persist(dupe); | ||||||||||||||||||||||
6 | tx.commit(); | 6 | tx.commit(); | |||||||||||||||||||||||
7 | s.close(); | 7 | s.close(); | |||||||||||||||||||||||
8 | s = openSession(); | 8 | s = openSession(); | |||||||||||||||||||||||
9 | tx = s.beginTransaction(); | 9 | tx = s.beginTransaction(); | |||||||||||||||||||||||
10 | s.persist(dupe); |
| | |||||||||||||||||||||||
11 | try |
| 10 | try | ||||||||||||||||||||||
|
| 11 | s.persist(dupe); | |||||||||||||||||||||||
12 | tx.commit(); |
| 12 | assertFalse(true); | ||||||||||||||||||||||
13 | assertFalse(true); | | ||||||||||||||||||||||||
14 | tx.rollback(); | 13 | tx.rollback(); | |||||||||||||||||||||||
15 | s.close(); | 14 | s.close(); | |||||||||||||||||||||||
| 15 | NumberedNode nondupe = new NumberedNode("nondupe"); | ||||||||||||||||||||||||
| 16 | nondupe.addChild(dupe); | ||||||||||||||||||||||||
16 | Node nondupe = new Node("nondupe"); | | ||||||||||||||||||||||||
17 | nondupe.addChild(dupe); | | ||||||||||||||||||||||||
18 | s = openSession(); | 17 | s = openSession(); | |||||||||||||||||||||||
19 | tx = s.beginTransaction(); | 18 | tx = s.beginTransaction(); | |||||||||||||||||||||||
20 | s.persist(nondupe); | | ||||||||||||||||||||||||
21 | try |
| 19 | try | ||||||||||||||||||||||
|
| 20 | s.persist(nondupe); | |||||||||||||||||||||||
22 | tx.commit(); |
| 21 | assertFalse(true); | ||||||||||||||||||||||
23 | assertFalse(true); | | ||||||||||||||||||||||||
24 | tx.rollback(); | 22 | tx.rollback(); | |||||||||||||||||||||||
25 | s.close(); | 23 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.ops.Node of variable dupe does not match with type org.hibernate.test.ops.NumberedNode of variable dupe |
2 | Type org.hibernate.test.ops.Node of variable dupe does not match with type org.hibernate.test.ops.NumberedNode of variable dupe |
3 | Unmatched statement s.persist(dupe); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement s.persist(dupe); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement s.persist(dupe); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
6 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
8 | Expression assertFalse(true) is a void method call, and thus it cannot be parameterized |
9 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
11 | Expression assertFalse(true) is a void method call, and thus it cannot be parameterized |
12 | Unmatched statement s.persist(nondupe); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
13 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
15 | Expression assertFalse(true) is a void method call, and thus it cannot be parameterized |
16 | Expression tx.commit() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression tx.commit() is a void method call, and thus it cannot be parameterized |
18 | Expression assertFalse(true) is a void method call, and thus it cannot be parameterized |