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: dynamic-update on custom value
PostPosted: Thu Apr 22, 2004 12:11 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
Hello,
What I need is functionality similar to dynamic-update and dynamic-insert but with these changes.

1. dynamic-update currently only updates properties that have changed. I would like to add an additional condition: only those properties that have changed AND do not contain a specific value (the value probably being specified in the mapping file).
2. dynamic-insert currently only inserts those properties that are not null. I would like to add the same additional condition: properties that are not null and do not contain a specific value

I first looked into implementing an Interceptor, but couldn't see how an interceptor could tell Hibernate which fields to insert or update dynamically. I've seen reports that findDirty's returned indices are ignored for dynamic updates? Also, I don't need or want to implement a dirty-finding algorithm, but I would be forced to if I took this approach. It still wouldn't help with inserts, though.
It looks like I might have to extend EntityPersister... but looking at what little docs I can find and the source for EntityPersister, this seems like a big time investment. My question: is there an easier way to do this? Or do I have to bite the bullet and implement and figure out EntityPersister?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Negative.

Use a custom type, or implement Interceptor.findDirty()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 2:21 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
1. findDirty might solve the issue for updates, but what about inserts?
2. The docs on findDirty don't specify what Hibernate does with the property index returned from findDirty. If I return an array of property indices, then does Hibernate only include those properties in the update? Does it do this regardless of the "dynamic-update" flag?
3. Implementing findDirty would allow me to return indices for the properties I want to update, but would also force me to detect if the entity is dirty. Is there a method in Hibernate somewhere that I can call from the interceptor that would tell me if an individual property is dirty, and also handle things like collections, cascades, and proxies automatically?


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.