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: Question About Criteria Queries
PostPosted: Mon Oct 02, 2006 4:17 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
I hope this isn't a stupid question . . . I read chapters 10-15 on querying and it doesn't explicitly say whether entities returned by Criteria queries are persistent or detached. Chapter 10 notes that entities returned by Query.list() are persistent, but there is no mention of Criteria.list().

The problem we are having is that during a session in which we perform multiple Criteria selects with filters, some of the entities are being flagged as dirty and an attempt is being made to flush those changes between queries.

We have some overlap between the queries (a customer query loads a customer and its accounts, and an account query may load the same accounts) and I suspect that with the filters it looks like some of the collections are being modified. Since this is a query service we would like to operate in a read-only mode, but I've not seen anything in the Criteria interface to control this. The Query interface has a setReadOnly method that would be perfect except we need to use Criteria due to the dynamic nature of the queries.

Are Criteria results detached or persistent? Is there a way to control this? Is there something in the Criteria interface that is comparable to the setReadOnly method of Query?

Thanks,

Jesse


Top
 Profile  
 
 Post subject: Criteria setReadOnly
PostPosted: Thu Aug 30, 2007 12:48 pm 
Newbie

Joined: Thu Aug 30, 2007 12:02 pm
Posts: 8
Has anyone ever responded to this question?

Is there any reason why Criteria doesn't offer setReadOnly method.

Is there any workaround to have the same behavior ?

Thank you,
Alain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 1:38 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I'm not sure if there's a valid reason for this or not. I do know that there isn't a hook to set it on the criteria and it always defaults to readOnly = false.

I clued into the setReadOnly after reading the new Hibernate book but apparently the example in there was a typo as the API didn't exist.

But digging into the source at the time I didn't see a reason why it couldn't be done but maybe there's a bigger technical reason that I didn't understand.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


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.