Nommi wrote:
so can u tell me how again i prevent it..
Hi Nommi,
what ever your app does and how consisted the Hibernate mappings are with your DB, I will show you how you can prevent the flushing of dirty objects when Hibernate is asked to do a query (remember, normally Hibernate flushes dirty entities to the DB before it will execute the query).
Code:
Query q = em.createQuery(.....)
q.setFlushMode(FlushMode.COMMIT);
Dirty entities will then only be written into the DB at commit time of your transaction.
PS: if you want to do real work with Hibernate, you have to eagerly study the Hibernate (and JPA) documentation. Better: read the Hibernate Book.
Carlo
---------------------------------------------
if this post helped you please give me credits