-->
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: putting into L2 cache
PostPosted: Wed Apr 11, 2007 6:10 pm 
Newbie

Joined: Wed Apr 11, 2007 5:54 pm
Posts: 4
Consider the following code:
Code:
Shipment shipment = new Shipment();
EntityTransaction txn = entityManager.getTransaction();
entityManager.persist(shipment);
txn.commit();

entityManager.refresh(shipment);
entityManager.close();

or

Code:
Transaction txn = session.beginTransaction();
Shipment shipment = new Shipment();
session.save(shipment);
session.flush();
txn.commit();

session.refresh(shipment);
session.close();


I noticed that nothing was put into the L2 cache after the commit. However, the refresh() would force a database select, and a CacheEntry will be created in the L2 cache.

Is it true that Hibernate only put into L2 cache after data is fetched from the database and not when a new transient entity is persisted?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Yes. Think about post insert db triggers and maintaining cached data integrity/accuracy.


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.