-->
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.  [ 5 posts ] 
Author Message
 Post subject: dirty checking, query, flushing and version
PostPosted: Thu Jul 28, 2005 3:31 am 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
hibernate 3.0.5

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
oracle 9.2.0.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi, i have a 'strange' situation here in my code. I'm using managed versioning for all of my tables.
Here's the sequence of my code does :
1. I update a persistent model (now it's dirty)
2. I execute a HQL query (the session flushed, the version of the persistent model get increased by 1)
3. I update the persistent model again (it gets dirty again)
4. The transaction ends, the session gets flushed and the version increases again.

Based on what i read on Hibernate in action, the session sometimes gets flushed (and got dirty models increase their version) before an execution of a query. If the result of the query could be affected by the modified persistent models, the session will flush first, and then the query gets executed.

The problem here is that, here in my case, i make a query to a table which doesnt have any relation at all to the modified persistent model, no relation at all in each hbm.xml. So it means that the result of the query wont be affected by the modification of the persistent model.

I wonder why the session flushes. The version gets increased twice. My preference is just to have the version increased only once (>.<)

Please help :)

Best regards,
Albert Kam

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 11:27 pm 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
helppp >.<

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 6:27 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
The simple solution would be to set the flushmode to never.
This has certainly some side effect.

Another solution would be (and you seem to have this one in mind)
to flush just the instance which could have influence on your
query. I am not sure about this one. Sorry.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 10:39 pm 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
Actually i just wonder why in this case it differs from what i read in the book.

Thanks a lot for the reply though ^-^

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 2:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You must have a broken getter or setter or something like that. Something that is dirtying an object each flush cycle.


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