-->
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.  [ 3 posts ] 
Author Message
 Post subject: Need to hit database for each query
PostPosted: Thu Jun 28, 2007 1:05 pm 
Newbie

Joined: Wed Oct 18, 2006 12:44 pm
Posts: 3
Hibernate version: 3.2
BEA WebLogic: 8.15

Just a simple query, and yes I have tried all possible solutions. I simply want to make sure that Hibernate does not load/persist data in cache, rather it should hit the database everytime.

This is what I have done so far:
1) Hibernate configuration:
<property name="query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>

<property name="hibernate.cache.use_query_cache">
false
</property>

<property name="hibernate.cache.use_second_level_cache">
false
</property>

2) All one-many relations (sets) have cascade="save-update" and lazy="false"

3) The DAO
session.setCacheMode(CacheMode.IGNORE);
session.setFlushMode(FlushMode.COMMIT);

4) Service layer:
AbstractDAO.save(object);
AbstractDAO.commit(transaction);
AbstractDAO.flush();

So is there still something that I am missing? I have been working in hibernate for 2 years but never ever have seen this behavior where it does not store data in db, but the data is available for view. I would really appreciate any help, otherwise I will only be left with switching to plain old JDBC and that does not look good :(. Thanks.

_________________
--
Regards,

Adeel Javed,
Software Engineer,
Techlogix Pakistan (Pvt) Limited.

Web: http://pkblogs.com/adeeljaved


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 1:16 pm 
Beginner
Beginner

Joined: Mon May 21, 2007 5:22 pm
Posts: 27
Location: Salt Lake City
AW,

Have you tried [quote]NoCacheProvider[/quote] for second level cache setting in the hibernate configuration file.

_________________
Try 'N' Enjoy !!
Rahul

If helpful do rating ....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 5:35 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
Even if you disable 2nd-level-cache hibernate will still cache the objects in its session-level persistence-context.

If you don't want this you could
1.) Use a StatelessSession instead of a Session. There's some things a StetelessSession won't do, so you better check out the documentation on this subject.
2.) clear() your session after every save()/update()/load()/get()....


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