Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sample example

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Christian and Gavin

I was working on the first example in the Hibernate Quickstart with Tomcat
guide. I created a servlet reads "Cat" objects into the database.After I ran the servlet,I manually updated the database row to change the weight column value. When I ran the servlet again, it was not displaying the new values for weight, it was displaying the old ones.

Does Hibernate cache data? If so, how to clear the cache?

Thanks a lot.
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caching objects. The session is a transaction-level cache of persistent objects. You may also enable a JVM-level JCS cache to memory and / or local disk.


From Performance Q&A

HTH, cheers,

Gian Franco Casula
 
Christian Bauer
author
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If "run" the servlet means hitting reload (a single Http request), then yes, but only if you somehow re-use the same Session instance to handle both requests. The global (SessionFactory scope) cache is also turned on (can be turned off), but actual data is not cached unless you set a caching strategy for each class/association in mapping or configuration files.

I'd say check your Session usage.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic