public void testCachedQueryOnInsert() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); Simple simple = new Simple(); simple.setName("Simple 1"); s.save( simple, new Long(10) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); Query q = s.createQuery("from Simple s"); List list = q.setCacheable(true).list(); assertTrue( list.size()==1 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==1 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); Simple simple2 = new Simple(); simple2.setCount(133); s.save( simple2, new Long(12) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==2 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==2 ); Iterator i = list.iterator(); while ( i.hasNext() ) s.delete( i.next() ); t.commit(); s.close();
public void testCachedQueryOnInsert() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); Simple simple = new Simple(); simple.setName("Simple 1"); s.save( simple, new Long(10) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); Query q = s.createQuery("from Simple s"); List list = q.setCacheable(true).list(); assertTrue( list.size()==1 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==1 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); Simple simple2 = new Simple(); simple2.setCount(133); s.save( simple2, new Long(12) ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==2 ); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); q = s.createQuery("from Simple s"); list = q.setCacheable(true).list(); assertTrue( list.size()==2 ); Iterator i = list.iterator(); while ( i.hasNext() ) s.delete( i.next() ); t.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public void testCachedQueryOnInsert() throws Exception {
1
public void testCachedQueryOnInsert() throws Exception {
2
		Session s = openSession();
2
		Session s = openSession();
3
		Transaction t = s.beginTransaction();
3
		Transaction t = s.beginTransaction();
4
		Simple simple = new Simple();
4
		Simple simple = new Simple();
5
		simple.setName("Simple 1");
5
		simple.setName("Simple 1");
6
		s.save( simple, new Long(10) );
6
		s.save( simple, new Long(10) );
7
		t.commit();
7
		t.commit();
8
		s.close();
8
		s.close();
9

10
		s = openSession();
9
		s = openSession();
11
		t = s.beginTransaction();
10
		t = s.beginTransaction();
12
		Query q = s.createQuery("from Simple s");
11
		Query q = s.createQuery("from Simple s");
13
		List list = q.setCacheable(true).list();
12
		List list = q.setCacheable(true).list();
14
		assertTrue( list.size()==1 );
13
		assertTrue( list.size()==1 );
15
		t.commit();
14
		t.commit();
16
		s.close();
15
		s.close();
17

18
		s = openSession();
16
		s = openSession();
19
		t = s.beginTransaction();
17
		t = s.beginTransaction();
20
		q = s.createQuery("from Simple s");
18
		q = s.createQuery("from Simple s");
21
		list = q.setCacheable(true).list();
19
		list = q.setCacheable(true).list();
22
		assertTrue( list.size()==1 );
20
		assertTrue( list.size()==1 );
23
		t.commit();
21
		t.commit();
24
		s.close();
22
		s.close();
25

26
		s = openSession();
23
		s = openSession();
27
		t = s.beginTransaction();
24
		t = s.beginTransaction();
28
		Simple simple2 = new Simple();
25
		Simple simple2 = new Simple();
29
		simple2.setCount(133);
26
		simple2.setCount(133);
30
		s.save( simple2, new Long(12) );
27
		s.save( simple2, new Long(12) );
31
		t.commit();
28
		t.commit();
32
		s.close();
29
		s.close();
33

34
		s = openSession();
30
		s = openSession();
35
		t = s.beginTransaction();
31
		t = s.beginTransaction();
36
		q = s.createQuery("from Simple s");
32
		q = s.createQuery("from Simple s");
37
		list = q.setCacheable(true).list();
33
		list = q.setCacheable(true).list();
38
		assertTrue( list.size()==2 );
34
		assertTrue( list.size()==2 );
39
		t.commit();
35
		t.commit();
40
		s.close();
36
		s.close();
41

42
		s = openSession();
37
		s = openSession();
43
		t = s.beginTransaction();
38
		t = s.beginTransaction();
44
		q = s.createQuery("from Simple s");
39
		q = s.createQuery("from Simple s");
45
		list = q.setCacheable(true).list();
40
		list = q.setCacheable(true).list();
46
		assertTrue( list.size()==2 );
41
		assertTrue( list.size()==2 );
47
		Iterator i = list.iterator();
42
		Iterator i = list.iterator();
48
		while ( i.hasNext() ) s.delete( i.next() );
43
		while ( i.hasNext() ) s.delete( i.next() );
49
		t.commit();
44
		t.commit();
50
		s.close();
45
		s.close();
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0