-->
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.  [ 9 posts ] 
Author Message
 Post subject: Session closing and cache
PostPosted: Wed Jun 02, 2004 10:22 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Hi,

I'd just like to know if when I close a session, do I need to empty the cache or is this going to be empty automaticaly. I need to work without cache because of the architecture of the application I use with different client speaking directly to database.

If my conf file is like the following, what about cache setting ?

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="connection.datasource">shark_hibernate</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>

<!-- to be used just for test
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.url">jdbc:postgresql://127.0.0.1:5432/shark</property>
<property name="connection.username">shark</property>
<property name="connection.password">shark</property>-->


<!-- Mapping files -->
<mapping resource="HibernateApplicationMapping.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 10:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the documentation, chapter "Performance".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 10:40 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Ok,

I had already read it, but I'd like to be sure to make the right think. With the configuration I have if I want to be sure that no cache is going to be used, I have to call session.clear() before the session.close() (or the last one is sufficient)?

This is the first point about Session cache, about second level cache, with my configuration, do I also need to empty the second level cache to ensure that nothing will be cached?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 10:42 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read it again. You don't have any second-level cache enabled (apparently) and you have to understand how the Session works before you think about its caching features. Short: The Session is the first level transaction-scoped cache and can't be turned off. The important thing here is "transaction scoped".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 11:27 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Thanks again for so quick response Christian.

In order to make sure, if I specify nothing more (no cache property) that what I have in the .cfg file and in the hbm I shoudn't have a second level cache enable, is this right?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 11:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
yes you're right

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 12:55 pm 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
That is good, but I noticed that the jar ehcache is requiered and even hibernate does not seem to work (ask for this library) without it, so it is not logic?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 1:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can set the cache.provider to HashTableCacheProvider if you don't like the dependency. Hibernate just loads EHCache per default, even if you don't use the cache.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 1:06 pm 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Ok thanks again fo the response.

By


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.