-->
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: Problem with query
PostPosted: Fri Jan 18, 2008 6:28 pm 
Newbie

Joined: Mon Jun 11, 2007 1:34 pm
Posts: 11
Hibernate version:
Hibernate 3.2.5
Hibernate Annotations 3.3.0.GA
Hibernate EntityManager 3.3.1.GA


Hi, i'm working just fine but i got a question.

I have a persisted object myInstance of class myClass. The class myClass has a boolean property named "active". myInstance's active value is true.

I change the myInstance's active property from true to false outside a transaction and don't do entityManager.update() on that object (in other words, i change the instance in memmory, not the database).

Then i do a query on this class asking for the objects that have active property value equal true and i get in that result myInstance. I know for sure that is myInstance becouse active property is false.

Just in case, the query is this:
Code:
Main.em.createQuery("from myClass where active = :active").setParameter("active", true).getResultList();


The query works just fine if i make entityManager.update(myInstance).

Is this behaviour ok?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 2:59 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
a query queries the database and not the memory. This might explain the behaviour.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 2:49 am 
Newbie

Joined: Mon Jun 11, 2007 1:34 pm
Posts: 11
ok, thank you for the reply.


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.