-->
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: Tracking a modification time with EJB3 annotations
PostPosted: Sat Oct 29, 2005 9:38 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
Hello, I'm having trouble keeping track of object "modification" / "last update" times. Here's what I have:

----
@PreUpdate
@PrePersist
public void onUpdateExisting(){
setModificationTime(System.currentTimeMillis());
}
----

This seemed natural enough, but it's causing problems. Just the act of reading an object from the EntityManager, and making no changes to it whatsoever, will cause it to be updated with new values upon flush.. I can tell because both the ModificationTime is being updated to a new value AND my Version column is being incremented.

Again, no other properties of the object are being updated. The object is only being read from (other objects are being updated). But, when the flush happens, this "only read" object is being updated with a new modification time and version.

I'm sure there is a correct place to be doing this kind of thing in EJB3 but I don't know where it is. Any ideas?

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 30, 2005 1:16 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
I removed my modification time update in the EJB3 callback as described above. However, the problem remains. Now, absolutely no columns are being updated by my code. Still, the simple act of reading the object from the database makes its version increment during the next flush / commit. This makes no sense to me. Why is the version being incremented when no changes are made to the object? For highly read objects, the version column's value is going to be out of control in no time... What am I missing here?

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 6:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Problem soved, was a wrong user type implementation.

_________________
Emmanuel


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.