-->
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.  [ 1 post ] 
Author Message
 Post subject: A horrible abuse of Hibernate that will make Gavin go bald
PostPosted: Thu Jun 30, 2005 8:36 am 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
I have to come right out and admit something: I like my many-to-many mappings. I know they're not encouraged, but something about being able to hide the complexity of managing an association table from my application code appeals to me. Sings to me, like a siren to my caffeine-addled brain.

Now I have a problem: when you remove items from the owning side of a bidirectional many-to-many, Hibernate updates the association table. When you do the same from the owned side, nothing happens. My solution?

Declare neither side as the inverse.

Yeah. I know.

It solves the removal problem neatly enough, allowing you to delete associations from either end. But when you go to insert new associations, this falls flat on its face. Now you have to remember to set only one side of the association, instead of both like you've been taught. Instead of using your nice addXXX and removeXXX helper methods, you end up calling entity.getCollection().add(xxx) and annotating your code with apologies to the reader for your horrible, horrible crimes.

Well, at least I have the good sense to be ashamed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.