-->
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: meaningful names for constraints in components
PostPosted: Sun Jun 01, 2008 8:33 am 
Newbie

Joined: Sun Apr 06, 2008 6:38 am
Posts: 4
I wanted to give meaningful names to my foreign keys & constraints.

Quite easy, I thought... Just add @ForeignKey on all the @ManyToOne properties that generate the foreign keys, and that's it...

But - This becomes a problem for properties inside reusable @Embeddable classes (e.g. Address)...

When several tables embed the Address component, the @ForeignKey attempts to create the same constraint name in all these tables.

This causes MYSQL to become very angry, because it requires uniqueness among all constraint names in a database.

How can I force a meaningful constraint name on fields of embeddable objects? I couldn't find a way to override the @ForeignKey definition at the 'instantiation' (@Embedded) location...

Any help would be appreciated.

Thanks,
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 7:54 pm 
Newbie

Joined: Fri Jan 02, 2009 4:26 pm
Posts: 5
I am also looking for the same thing but for a different reason. I have @MappedSuperclass's and @Inheritance classes w/ foreign keys that I need custom names for to keep my dba happy.

Since the annotation will always have problems w/ dynamic generation, I think updating the NamingStrategy iface (mentioned in this post) would be the best solution.

I attempted a custom dialect extension but the getAddPrimaryKeyConstraintString only contains one of the two table names I need to generate a friendly FK name.

Would a patch to NamingStrategy (w/ impl's in Default and Improved) be accepted?


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.