-->
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: Hibernate 3.x - inverse="true" doesn't stop foreig
PostPosted: Tue Nov 29, 2005 2:28 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Hibernate version:
3.1 mainline

I have been porting an application from Hibernate 2.1.[latest] to Hibernate 3.1 (working off of mainline right now).

I noticed that foreign keys are now generated by default on all collections, regardless of the value of the inverse attribute. In Hibernate 2.1, inverse="true" would prevent a foreign key from being generated (which made sense).

Now it appears the only way to override this is to add a foreign-key="none" attribute on the key element.

This is caused by an if block being removed (note the // comments) in org.hibernate.mapping.Collection:

Code:
   private void createForeignKeys() throws MappingException {
      // if ( !isInverse() ) { // for inverse collections, let the "other end" handle it
      if ( referencedPropertyName == null ) {
         getElement().createForeignKey();
         key.createForeignKeyOfEntity( getOwner().getEntityName() );
      }
      // }
   }


I trolled through the CVS logs in org.hibernate.mapping.Collection and found the checkin where this was commented out:

http://cvs.sourceforge.net/viewcvs.py/h ... 1.3&r2=1.4
http://cvs.sourceforge.net/viewcvs.py/h ... iew=markup

I looked at the bugs referenced in the checkin, and didn't see any reason in the bugs why this would have been disabled (although I don't have access to the TODO-50 bug).

I was going to add a note to the Hibernate 3 migration wiki page, but I figured I'd check in here first.

Thanks ~
Peter


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.