-->
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.  [ 4 posts ] 
Author Message
 Post subject: EntityManager and Caching
PostPosted: Mon Mar 31, 2008 11:03 am 
Newbie

Joined: Wed Feb 13, 2008 6:38 am
Posts: 5
Location: Germany - Leipzig
Hello,

in my application i use the JPA EntityManager with Hibernate.
The PostgreSQL DB was used from other Applications with plain JDBC.

I have disabled the QueryCache and the SecondLevelCache but my application don't show the same content from the DB after a transaction outside of my application.

Does anyone now how i can disable the Session Caching?



Code:
   <persistence-unit name="gpke" transaction-type="RESOURCE_LOCAL">
.
.
.
      <properties>
         <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
          <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
         <property name="hibernate.connection.url" value="jdbc:postgresql://lvappdb:5432/mydb" />
         <property name="hibernate.connection.username" value="xxxx" />
         <property name="hibernate.connection.password" value="xxxx" />
         <property name="hibernate.show_sql" value="true" />
         <property name="hibernate.format_sql" value="true" />
         <property name="hibernate.generate_statistics" value="true" />
         <property name="hibernate.cache.use_second_level_cache" value="false" />
         <property name="hibernate.cache.use_query_cache" value="false" />
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
         
         <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
         <property name="c3p0.acquire_increment" value="3" />
         <property name="c3p0.idle_test_period" value="300" />
         <property name="c3p0.initialPoolSize" value="10" />
         <property name="c3p0.min_size" value="5" />
         <property name="c3p0.max_size" value="15"/>
         <property name="c3p0.timeout" value="1800" />
      </properties>
   </persistence-unit>




Any advice will be welcome


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2008 11:57 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
u can use stateless session, but u loose a lot of features

http://www.hibernate.org/hib_docs/v3/re ... esssession


or u can evict object from session cache by calling session.evict(object) or refresh his state from database by calling session.refresh(object)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2008 12:39 pm 
Newbie

Joined: Wed Feb 13, 2008 6:38 am
Posts: 5
Location: Germany - Leipzig
hello ferozz,

thank you for your replay.
I don't use Hibernate directly. How can I use this Stateless Session with the EntityManager?

Code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("gpke");
EntityManager manager = emf.createEntityManager();
List ln = manager.createQuery(queryString).getResultList();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 2:31 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
hmm don`t know if it is possible to use stateless session in your case.

hmm not nice solution but still u can clear session cache(persistence context) and then load objects from db

or dont have opened session for long time and always load objects from db

cant help more


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