-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Caching problem with read-write mode
PostPosted: Fri Dec 01, 2006 6:13 pm 
Newbie

Joined: Fri Dec 01, 2006 5:51 pm
Posts: 4
Hi guys,

I'm new to Hibernate and I'm having a problem with second-level caching in read-write mode.
I have searched the internet and the forum, I fould a similar problem (http://forum.hibernate.org/viewtopic.ph ... 0c2e1cd6b7). However, my problem is a bit different.

The problem is: my code is only a simple piece like this:
Code:
//Open session & Start transaction
TestObj o1 = (TestObj)hibernateSession.get(TestObj.class, 1);
TestObj o2 = (TestObj)hibernateSession.get(TestObj.class, 2);
TestObj o3 = (TestObj)hibernateSession.get(TestObj.class, 3);
//Comit transaction & close transaction

//a few moment latter (still the same SessionFactory)
//Open session & Start transaction
TestObj to1 = (TestObj)hibernateSession.get(TestObj.class, 1);
TestObj to2 = (TestObj)hibernateSession.get(TestObj.class, 2);
TestObj to3 = (TestObj)hibernateSession.get(TestObj.class, 3);
//Comit transaction & close transaction


When to1, to2 and to3 are loaded, there are excatly 3 SELECT queries in postgresql's log like this:
Code:
LOG:  duration: 0.023 ms  statement: EXECUTE <unnamed>  [PREPARE:  select testobj0_.id as id19_0_, testobj0_.v as v19_0_ from
tblTest testobj0_ where testobj0_.id=$1]


When I switch from <cache usage="read-write" />
to <cache usage="nonstrict-read-write" />
this does not happen anymore.

I don't really know what's wrong with my read-write caching setting :-(
Any help is appreciated :-)

Regards,
Tom

My hibernate configurations are as the following:

Hibernate version: 3.2.1-GA
2nd-level Cache: EhCache 1.2.4RC

Mapping documents:
The database table:
Code:
CREATE TABLE tbltest (
  id serial,
  v integer NOT NULL,
  primary key (id)
)


Mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test">
   <class name="TestObj" table="tblTest">
      <cache usage="read-write" />
      <id name="id" column="id" type="integer">
         <generator class="identity" />
      </id>
      <property name="value" column="v" type="integer"
         not-null="true" />
   </class>
</hibernate-mapping>


Name and version of the database you are using: Postgresql 8.1 on Fedora Core 5 box


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 03, 2006 4:44 am 
Newbie

Joined: Fri Dec 01, 2006 5:51 pm
Posts: 4
up...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.