| Author |
Message |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 08:07:43
|
juanux
journeyman
Joined: 10/06/2009 08:12:36
Messages: 12
Location: Colombia
Offline
|
*****
neo
Joined: 10/06/2009 08:12:36
Messages: 7
Location: Colombia
Online
Hi
Here's an example of test that reproduces the problem we've been having.
As they realize the problem can be seen most clearly when there are multiple sessions and threads running.
public static void testGetEmployeeWithThreads(){
EhCacheTestThread thread1 = new EhCacheTestThread();
thread1.setName("T1");
EhCacheTestThread thread2 = new EhCacheTestThread();
thread2.setName("T2");
EhCacheTestThread thread3 = new EhCacheTestThread();
thread3.setName("T3");
EhCacheTestThread thread4 = new EhCacheTestThread();
thread4.setName("T4");
System.out.println("Start t1");
thread1.start();
System.out.println("Start t2");
thread2.start();
System.out.println("Start t3");
thread3.start();
System.out.println("Start t4");
thread4.start();
}
I use the class EhCacheTestThread with the following method:
public void run() {
testGetEmployee();
}
/**
* Generic test with get employees.
* @author Juan Morales
*/
public void testGetEmployee(){
List<Long> employeeKeys = null;
Session session = null;
String sql = "select employee_key from employee";
employeeKeys = intHibernateUtil.getCurrentSession().createSQLQuery(sql)
.addScalar("employee_key", Hibernate.LONG)
.list();
while(true){
session = HibernateUtil.createSession();
try{
for(Long key : employeeKeys){
session.get(DBEmployee.class,key);
}
session.close();
sleep(1000);
}catch(Exception e){
session.close();
e.printStackTrace();
}
}
}
You can see the state of the threads with Jconsole and the hibernate queries
in the java output console
we appreciate if you can help us.
thanks beforehand.
juanux
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 13:49:48
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Neo
1. What exactly is the problem?
2. I think you are missing some files that you meant to attach
Greg
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 13:50:15
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Oh, also, what version of ehcache and Hibernate are you taking about?
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 14:55:40
|
juanux
journeyman
Joined: 10/06/2009 08:12:36
Messages: 12
Location: Colombia
Offline
|
the problem is that although the Employee table is in the second level cache, running these code you can be seen in the consolea big lot of hibernate queries from this table.
we´re using ehcache 1.7 and hibernate 3.
we have the following configuration:
<cache name="mint.hibernate.bean.MintDBEmployee"
maxElementsInMemory="30000"
eternal="true"
overflowToDisk="false"
>
<!--! init=staff_tree_key = 1 and rownum <= 30000 -->
</cache>
We using ehcache as part of the core of our system
we appreciate if you can help us with it.
thank u so much
| Filename |
MintEhCacheTestThread.java |
Download
|
| Description |
here we made the ehcache queries |
| Filesize |
1 Kbytes
|
| Downloaded: |
137 time(s) |
| Filename |
MintEhCacheTestAPI.java |
Download
|
| Description |
Test that describe the probles
exactly
testEmployeeWithThreads |
| Filesize |
7 Kbytes
|
| Downloaded: |
140 time(s) |
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 18:40:00
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
I see most of your example use are using createSQLQuery.
Firstly can you please rerun your tests against ehcache-1.5 and report the results.
If the issue is still there it is not an ehcache issue. You may be seeing a Hibernate bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-2470
Can I also see your ehcache.xml?
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/22/2009 18:54:10
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Another thing. See http://74.125.95.132/search?q=cache:jfMvhPgRyi8J:i-proving.ca/space/Technologies/Hibernate/SQL%2Bvs%2BHQL%2Bwith%2Bthe%2BSession%2BCache+hibernate+create+sql+query+caching&cd=1&hl=en&ct=clnk&client=safari
He seems to be saying that SQLQuery' will not use the cache. I know that Hibernate bypasses the cache for Stored Procedures. See if you can restate the queries in HQL and follow the caching doco here:
http://docs.jboss.org/hibernate/stable/core/reference/en/html/performance.html#performance-cache
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/23/2009 05:19:48
|
juanux
journeyman
Joined: 10/06/2009 08:12:36
Messages: 12
Location: Colombia
Offline
|
Hi
the createSqlQuery statment is use just for get the keys for the test...
the real problem is
getSession().get(MinDBEmployee,key);
when we use it in a concurrent context
we get a lot af hibernate queries in the java output console.
attached ehcache.xml
thanks for you help
| Filename |
ehcache.cfg.xml |
Download
|
| Description |
|
| Filesize |
3 Kbytes
|
| Downloaded: |
112 time(s) |
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/23/2009 05:20:58
|
juanux
journeyman
Joined: 10/06/2009 08:12:36
Messages: 12
Location: Colombia
Offline
|
Hi
the createSqlQuery statment is use just for get the keys for the test...
the real problem is
getSession().get(MinDBEmployee,key);
when we use it in a concurrent context
we get a lot af hibernate queries in the java output console.
attached ehcache.xml
thanks for you help
| Filename |
ehcache.cfg.xml |
Download
|
| Description |
|
| Filesize |
3 Kbytes
|
| Downloaded: |
129 time(s) |
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/23/2009 05:26:42
|
juanux
journeyman
Joined: 10/06/2009 08:12:36
Messages: 12
Location: Colombia
Offline
|
Hi
the createSqlQuery statment is use just for get the keys for the test...
the real problem is
getSession().get(MinDBEmployee,key);
when we use it in a concurrent context
we get a lot af hibernate queries in the java output console.
attached ehcache.xml
thanks for you help
| Filename |
ehcache.cfg.xml |
Download
|
| Description |
|
| Filesize |
3 Kbytes
|
| Downloaded: |
120 time(s) |
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 10/23/2009 16:34:39
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Ok
Well I cannot run your tests.
Can you please try with ehcache-1.5 and report the results? That will help to isolate it.
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 07/18/2011 02:17:29
|
rajoshi
seraphim
Joined: 07/04/2011 04:36:10
Messages: 1465
Offline
|
The issue seems to be resolved.Please let know in case of more information.
|
Rakesh Joshi
Terracotta. |
|
|
 |
|
|