-->
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.  [ 2 posts ] 
Author Message
 Post subject: Automatically balancing associations in setters
PostPosted: Tue Jul 05, 2005 8:45 am 
Newbie

Joined: Fri Jul 01, 2005 5:45 pm
Posts: 2
Location: RTP, NC
We would like to automatically balance our bidirectional associations in the setters.
That is, when we call a setter for one end of an association, if the value has changed,
we would like to update the other end.

However, when hibernate calls the setters (e.g., during find,save,update,factory creation)
we do not want to call the balancing code.

We are using hibernate version 2.1.8.

We had the idea, and also saw it in the FAQ, of creating new setters (setXxxByApp)
that do the balancing.
This will certainly work, but has a few drawbacks.
Are there any other ways to accomplish this?

One other idea is to wrap the hibernate query, save/update, and factory creation calls and
set global variables to indicate we are in hibernate code. Then the regular setters could
check these variables to determine if they should rebalance.
The main problem with this is for lazy initialization.
We have some big sets for which we do want lazy initialization.

Any other ideas/patterns for this?

-buddy


Top
 Profile  
 
 Post subject: Re: Automatically balancing associations in setters
PostPosted: Fri Jul 15, 2005 3:15 pm 
Newbie

Joined: Fri Jul 01, 2005 5:45 pm
Posts: 2
Location: RTP, NC
We just came across this in the documentation:

--
<property
name="propertyName" (1)
...
access="field|property|ClassName" (6)
/>
If you specify access="field", Hibernate will bypass the get/set pair and access the field directly, using reflection.
--

So, we're going to try it.
If it works, we can do balancing, committing,
anything we want in the setters.

Any drawbacks to this?

-buddy


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