-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can I name a foreign-key constraint?
PostPosted: Mon Jun 28, 2004 4:04 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 6:46 pm
Posts: 41
Location: Auckland, New Zealand
Hi

I'm using XDoclet 1.2 with Hibernate 2.1.3 and it's all going well.

When I use schemaUpdate to build tables, etc in my database it all works nicely except that the names given to foreign key constraints are generated (and hence ugly). I'd really like to be able to name them. Is there any way I can do this with with the mapping document, and (hence?) from xdoclet?

Thanks,

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 8:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Currently there is not a way to name generated FK constraints.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 3:42 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 6:46 pm
Posts: 41
Location: Auckland, New Zealand
Thanks for the reply Steve.

I've created a new feature request in Jira.

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 5:00 pm 
Beginner
Beginner

Joined: Wed Nov 19, 2003 6:46 pm
Posts: 41
Location: Auckland, New Zealand
More information!

I put in a new feature request in Jira, but actually, the functionality already exists. To quote Christian...

Message:

The following issue has been closed.

Resolver: Christian Bauer
Date: Wed, 30 Jun 2004 8:59 AM

This functionality already exists, use the "foreign-key" attribute on <one-to-one>, <many-to-one>, <key>, and <many-to-many> mapping elements. Note that inverse="true" sides will not be used, only the non-inverse side will be looked at for the constraint names.



So, I tried this out, but version 1.2 of XDoclet doesn't support the foreign-key tags, only 1.2.1 of XDoclet.

I must also say that I'm very impressed with the way that XDoclet generates the mapping documents in that it respects inheritance properly.

In my situation I have a many-to-one relationship defined in a superclass, but I can still name the foreign-key constraint in the subclass, simply by overriding the method to just call the superclass method, but providing the @hibernate.many-to-one foreign-key="fk..." tag in the subclass. Very nice!

Well done XDoclet and Hibernate!


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