-->
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: Hibernate Cache Problem with MySQL -- urgent
PostPosted: Mon Jan 17, 2005 11:23 am 
Newbie

Joined: Wed Apr 21, 2004 5:06 am
Posts: 7
Location: India
I have two application running on JBoss 3.2.5 with Jetty 5.0
The first application adds some data into the data base.
The second application uses that data to generate reports.

When i am adding the data using the first application and then retriving the data with second application to generate reports, i am not getting the latest recrods(data) back in the second application.
The same application perfectly runs with PostgreSQL without any problem of this caching, but when i migrated to MySQL, this is the problem that i am getting.
Following the code which save the data into the data base.
I have not enabled the autocommit in the hibernate.properties, as i am using the hibernate transaction.

Hibernate version:2.1

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.vo.common.PlantVO" table="plant">
<id name="plantID" column="plantidin" type="int">
<generator class="identity">
</generator>
</id>
<property name="plantName" column="plantnamevc"/>
<property name="plantCode" column="shortcodevc"/>
<property name="address1" column="address1vc"/>
<property name="address2" column="address2vc"/>
<property name="address3" column="address3vc"/>
<property name="city" column="cityvc"/>
<property name="county" column="countyvc"/>
<property name="state" column="statevc"/>
<property name="zip" column="zipvc"/>
<property name="country" column="countryvc"/>
<property name="phone1" column="phone1vc"/>
<property name="phone2" column="phone2vc"/>
<property name="fax1" column="fax1vc"/>
<property name="fax2" column="fax2vc"/>
<property name="comments" column="commentsvc"/>
<property name="status" column="statusvc"/>
<property name="location" column="locationvc"/>
<property name="entryDate" column="entrydatedt"/>
<property name="tollFreeNo" column="tollfreenumbervc"/>
</class>
</hibernate-mapping>



Session mSession = null;
Transaction mTx=null;
try
{
mSession = getSession();
mTx = mSession.beginTransaction();
mSession.save(pPlantVO);
mTx.commit();
}
catch (Exception pEx)
{
if(mTx!= null)
{
mTx.rollback();
}
handleException(pEx.getClass() ,pEx);
}
finally
{
try
{
closeSession();
}
catch (Exception pExFinally)
{
handleException(pExFinally.getClass(),pExFinally);
}
}


Full stack trace of any exception that occurs:

MySQL 4.1.8

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Thanks in advance
bapi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 12:41 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
You have two separate applications. Each has its own instance of the hibernate SessionFactory, and therefore its own copy of the second-level cache. (Go read up on caching, this is pretty straightforward.)

So, no matter what kind of autocommit/transactional scheme you use, the second level caches of each application will get out of sync. You need to use some kind of "shared" or "clustered" cache for your application. You can use JBoss TreeCache, SwarmCache, or OSCache (with a patched Cache provider). Each of these caches are capable of communicating cache events between the caches. TreeCache uses a granular approach, whilel OSCache and SwarmCache use a "clustered eviction" strategy. I've used both TreeCache and OSCache will success.

The default cache used by Hibernate is EHCache, which will not provide intra-application caching. There's plenty of material on using all three of those caches. Go do some reading and some experimentation, and then post if you get stuck.


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.