File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java | |||
Method name: void testInsertWithGeneratedVersionAndId()
|
Method name: void testInsertWithGeneratedTimestampVersion()
|
|||
Number of AST nodes: 29 | Number of AST nodes: 31 | |||
1 | if ( !supportsBulkInsertIdGeneration( IntegerVersioned.class ) ) {↵ | 1 | if ( !supportsBulkInsertIdGeneration( TimestampVersioned.class ) ) {↵ | |
2 | reportSkip( "bulk id generation not supported", "test bulk inserts with generated id and generated timestamp");↵ | 2 | reportSkip( "bulk id generation not supported", "test bulk inserts with generated id and generated timestamp");↵ | |
3 | return;↵ | 3 | return;↵ | |
4 | }↵ | 4 | }↵ | |
5 | // dialects which do not allow a parameter in the select portion of an INSERT ... SELECT statement↵ | |||
6 | // will also be problematic for this test because the timestamp here is vm-based as opposed to↵ | |||
7 | // db-based.↵ | |||
8 | if ( ! getDialect().supportsParametersInInsertSelect() ) {↵ | |||
9 | reportSkip( "dialect does not support parameter in INSERT ... SELECT",↵ | |||
10 | "test bulk inserts with generated id and generated timestamp");↵ | |||
11 | return;↵ | |||
12 | }↵ | |||
5 | Session s = openSession();↵ | 13 | Session s = openSession();↵ | |
6 | Transaction t = s.beginTransaction();↵ | 14 | Transaction t = s.beginTransaction();↵ | |
7 | IntegerVersioned entity = new IntegerVersioned( "int-vers" );↵ | 15 | TimestampVersioned entity = new TimestampVersioned( "int-vers" );↵ | |
8 | s.save( entity );↵ | 16 | s.save( entity );↵ | |
9 | s.createQuery( "select id, name, version from IntegerVersioned" ).list();↵ | 17 | s.createQuery( "select id, name, version from TimestampVersioned" ).list();↵ | |
10 | t.commit();↵ | 18 | t.commit();↵ | |
11 | s.close();↵ | 19 | s.close();↵ | |
12 | Long initialId = entity.getId();↵ | 20 | Long initialId = entity.getId();↵ | |
13 | int initialVersion = entity.getVersion();↵ | 21 | //Date initialVersion = entity.getVersion();↵ | |
14 | s = openSession();↵ | 22 | s = openSession();↵ | |
15 | t = s.beginTransaction();↵ | 23 | t = s.beginTransaction();↵ | |
16 | int count = s.createQuery( "insert into IntegerVersioned ( name ) select name from IntegerVersioned" ).executeUpdate();↵ | 24 | int count = s.createQuery( "insert into TimestampVersioned ( name ) select name from TimestampVersioned" ).executeUpdate();↵ | |
17 | t.commit();↵ | 25 | t.commit();↵ | |
18 | s.close();↵ | 26 | s.close();↵ | |
19 | assertEquals( "unexpected insertion count", 1, count );↵ | 27 | assertEquals( "unexpected insertion count", 1, count );↵ | |
20 | s = openSession();↵ | 28 | s = openSession();↵ | |
21 | t = s.beginTransaction();↵ | 29 | t = s.beginTransaction();↵ | |
22 | IntegerVersioned created = ( IntegerVersioned ) s.createQuery( "from IntegerVersioned where id <> :initialId" )↵ | 30 | TimestampVersioned created = ( TimestampVersioned ) s.createQuery( "from TimestampVersioned where id <> :initialId" )↵ | |
23 | .setLong( "initialId", initialId.longValue() )↵ | 31 | .setLong( "initialId", initialId.longValue() )↵ | |
24 | .uniqueResult();↵ | 32 | .uniqueResult();↵ | |
25 | t.commit();↵ | 33 | t.commit();↵ | |
26 | s.close();↵ | 34 | s.close();↵ | |
27 | ↵ | 35 | assertNotNull( created.getVersion() );↵ | |
28 | assertEquals( "version was not seeded", initialVersion, created.getVersion() );↵ | 36 | //assertEquals( "version was not seeded", initialVersion, created.getVersion() );↵ | |
29 | s = openSession();↵ | 37 | s = openSession();↵ | |
30 | t = s.beginTransaction();↵ | 38 | t = s.beginTransaction();↵ | |
31 | s.createQuery( "delete IntegerVersioned" ).executeUpdate();↵ | 39 | s.createQuery( "delete TimestampVersioned" ).executeUpdate();↵ | |
32 | t.commit();↵ | 40 | t.commit();↵ | |
33 | s.close(); | 41 |
| |
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.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 184 |
Number of mapped statements | 26 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 44.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (!supportsBulkInsertIdGeneration(IntegerVersioned.class)) |
| 1 | if (!supportsBulkInsertIdGeneration(TimestampVersioned.class)) | |||||||||||||||||||||
2 | reportSkip("bulk id generation not supported", "test bulk inserts with generated id and generated timestamp"); | 2 | reportSkip("bulk id generation not supported", "test bulk inserts with generated id and generated timestamp"); | ||||||||||||||||||||||
3 | return; |
| 3 | return; | |||||||||||||||||||||
4 | Session s = openSession(); | 7 | Session s = openSession(); | ||||||||||||||||||||||
5 | Transaction t = s.beginTransaction(); | 8 | Transaction t = s.beginTransaction(); | ||||||||||||||||||||||
6 | IntegerVersioned entity = new IntegerVersioned("int-vers"); |
| | ||||||||||||||||||||||
|
| 9 | TimestampVersioned entity = new TimestampVersioned("int-vers"); | ||||||||||||||||||||||
7 | s.save(entity); |
| 10 | s.save(entity); | |||||||||||||||||||||
8 | s.createQuery("select id, name, version from IntegerVersioned").list(); |
| 11 | s.createQuery("select id, name, version from TimestampVersioned").list(); | |||||||||||||||||||||
9 | t.commit(); | 12 | t.commit(); | ||||||||||||||||||||||
10 | s.close(); | 13 | s.close(); | ||||||||||||||||||||||
11 | Long initialId = entity.getId(); |
| 14 | Long initialId = entity.getId(); | |||||||||||||||||||||
12 | int initialVersion = entity.getVersion(); | | |||||||||||||||||||||||
13 | s = openSession(); | 15 | s = openSession(); | ||||||||||||||||||||||
14 | t = s.beginTransaction(); | 16 | t = s.beginTransaction(); | ||||||||||||||||||||||
15 | int count = s.createQuery("insert into IntegerVersioned ( name ) select name from IntegerVersioned").executeUpdate(); |
| 17 | int count = s.createQuery("insert into TimestampVersioned ( name ) select name from TimestampVersioned").executeUpdate(); | |||||||||||||||||||||
16 | t.commit(); | 18 | t.commit(); | ||||||||||||||||||||||
17 | s.close(); | 19 | s.close(); | ||||||||||||||||||||||
18 | assertEquals("unexpected insertion count", 1, count); | 20 | assertEquals("unexpected insertion count", 1, count); | ||||||||||||||||||||||
19 | s = openSession(); | 21 | s = openSession(); | ||||||||||||||||||||||
20 | t = s.beginTransaction(); | 22 | t = s.beginTransaction(); | ||||||||||||||||||||||
21 | IntegerVersioned created = (IntegerVersioned)s.createQuery("from IntegerVersioned where id <> :initialId").setLong("initialId", initialId.longValue()).uniqueResult(); |
| | ||||||||||||||||||||||
|
| 23 | TimestampVersioned created = (TimestampVersioned)s.createQuery("from TimestampVersioned where id <> :initialId").setLong("initialId", initialId.longValue()).uniqueResult(); | ||||||||||||||||||||||
22 | t.commit(); | 24 | t.commit(); | ||||||||||||||||||||||
23 | s.close(); | 25 | s.close(); | ||||||||||||||||||||||
24 | assertEquals("version was not seeded", initialVersion, created.getVersion()); |
| 26 | assertNotNull(created.getVersion()); | |||||||||||||||||||||
25 | s = openSession(); | 27 | s = openSession(); | ||||||||||||||||||||||
26 | t = s.beginTransaction(); | 28 | t = s.beginTransaction(); | ||||||||||||||||||||||
27 | s.createQuery("delete IntegerVersioned").executeUpdate(); |
| 29 | s.createQuery("delete TimestampVersioned").executeUpdate(); | |||||||||||||||||||||
28 | t.commit(); | 30 | t.commit(); | ||||||||||||||||||||||
29 | s.close(); | 31 | s.close(); |
Row | Violation |
---|---|
1 | Conditional return; |
2 | Unmatched statement IntegerVersioned entity=new IntegerVersioned("int-vers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement TimestampVersioned entity=new TimestampVersioned("int-vers"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Type org.hibernate.test.hql.IntegerVersioned of variable entity does not match with type org.hibernate.test.hql.TimestampVersioned of variable entity |
5 | Type org.hibernate.test.hql.IntegerVersioned of variable entity does not match with type org.hibernate.test.hql.TimestampVersioned of variable entity |
6 | Unmatched statement IntegerVersioned created=(IntegerVersioned)s.createQuery("from IntegerVersioned where id <> :initialId").setLong("initialId",initialId.longValue()).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement TimestampVersioned created=(TimestampVersioned)s.createQuery("from TimestampVersioned where id <> :initialId").setLong("initialId",initialId.longValue()).uniqueResult(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression assertEquals("version was not seeded",initialVersion,created.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression assertNotNull(created.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression assertEquals("version was not seeded",initialVersion,created.getVersion()) is a void method call, and thus it cannot be parameterized |
11 | Expression assertNotNull(created.getVersion()) is a void method call, and thus it cannot be parameterized |
12 | Expression assertEquals("version was not seeded",initialVersion,created.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression assertNotNull(created.getVersion()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression assertEquals("version was not seeded",initialVersion,created.getVersion()) is a void method call, and thus it cannot be parameterized |
15 | Expression assertNotNull(created.getVersion()) is a void method call, and thus it cannot be parameterized |
16 | Clone fragment #1 returns variables initialId, s , while Clone fragment #2 returns variables initialId, s |