-->
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: Hiberante many-to-many approach / Silent Properties Feature?
PostPosted: Fri Aug 06, 2004 10:47 am 
Newbie

Joined: Thu Oct 09, 2003 11:11 am
Posts: 5
I have Person and Club Entities with a many to many. I wanted club to contain a set of Person object. But I do not want Person to have a set of Club. This was set up by declaring a set in the Club, with a many to many on a table called ClubMembers.

The reason I do not want the set in the Person is simple. I anticipate on the order of a dozen or so relationships between person and other Entities. If I was to load one person - then Hibernate will end up loading just about all of the Data in the DB. Not pretty.

When I go ahead and create the set mapping in Person. Then just a simple session.delete(person) also logs

delete from ClubMembers where person_id=?

So, If I remove this set from person - where is the "right place" to add this functionality. I am using Hibernate Synchronizer - and it looks like I can extend the Delete() methods to also make this straight forward SQL call.

The Interceptor looks like a bad place to put it - because it is not aware of the current session.

Implementing the delete() lifecycle method is a little more tricky - because of how I want POJO to keep the P part intact - why muddle up the value object with Persistence Logic?

So my options seem to be A) DB Trigger. B) DAO Code. What would you choose?

BTW - What would be great is in HBM to denote a relationship - but not have it considered in loading the POJO. I would like to tell Hibernate - when a person is deleted - to go out and delete any ClubMember records that it is in. But also that i really do not want users of the Person POJO to inspect or muddle with the relationship. This sounds to me like an attribute could be added to just about any mapping element as "silent". Meaning i could still use it in Queries or for helping cascades - but I just don't want the state ever loaded. (A bit different from lazy)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
BTW - What would be great is in HBM to denote a relationship - but not have it considered in loading the POJO. I would like to tell Hibernate - when a person is deleted - to go out and delete any ClubMember records that it is in. But also that i really do not want users of the Person POJO to inspect or muddle with the relationship. This sounds to me like an attribute could be added to just about any mapping element as "silent". Meaning i could still use it in Queries or for helping cascades - but I just don't want the state ever loaded. (A bit different from lazy)

Actually it's exactly the same as mapping the collection as lazy to a private property or field which is not exposed to the users of your Person class. Then just define the appropriate cascade semantics on the collection mapping. This approach makes you initial question mute.


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.