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
|