[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-682) @ForeignKey override of @MappedSuperclass
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Wed Nov 21 09:37:56 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28913 ]
Emmanuel Bernard commented on ANN-682:
--------------------------------------
IM chat:
don't know if you want/can do anything about this:
@ForeignKey in a @MappedSuperclass is inherited in subclasses
so these all get the same FK name in the catalog
which doesn't work
so right now i don't see a way to have a @ManyToOne in a @MappedSuperclass and then customize the foreign key constraint
emmanuel 09:32
I see. Yes open a JIRA issue.
I'm not sure how to solve that cleanly though
christian 09:32
maybe a hibernate specific @AttributeOverride
emmanuel 09:33
yes that could do it
> @ForeignKey override of @MappedSuperclass
> -----------------------------------------
>
> Key: ANN-682
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-682
> Project: Hibernate Annotations
> Issue Type: New Feature
> Components: binder
> Reporter: Christian Bauer
>
> Put this @ManyToOne in a @MappedSuperclass:
> @ManyToOne(fetch = FetchType.LAZY)
> @JoinColumn(name = "CREATED_BY_USER_ID", nullable = false)
> // Ideally this foreign key should be ON DELETE SET NULL, however...
> // Hibernate can't rename these so subclasses would get the same FK constraint name. This doesn't
> // work, so we need to let Hibernate create a random identifier for these. We could fix this in the
> // DatabaseObjects.hbm.xml file but we can't even address it because the name is random. This sucks.
> // So we do a manual SET NULL|DEFAULT when userHome.remove() is called.
> // @org.hibernate.annotations.ForeignKey(name = "FK_WIKI_NODE_CREATED_BY_USER_ID")
> protected User createdBy;
> Now all subclasses get that foreign key constraint name in the database catalog, which isn't possible - constraint names have to be unique.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list