[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3499) NamingStrategy should support naming foreign keys and indexes
Geoffrey De Smet (JIRA)
noreply at atlassian.com
Mon Sep 29 09:56:04 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31296#action_31296 ]
Geoffrey De Smet commented on HHH-3499:
---------------------------------------
typo: Please replace "@Index" with "@ForeignKey" in the text above.
> NamingStrategy should support naming foreign keys and indexes
> -------------------------------------------------------------
>
> Key: HHH-3499
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3499
> Project: Hibernate Core
> Issue Type: Improvement
> Components: metamodel
> Affects Versions: 3.3.1
> Reporter: Geoffrey De Smet
>
> hbm2ddl always generates foreign key constraints based on hashcodes, like this:
> alter table apple add index FK365FA4BB24B1D45C (lemon_id), add constraint FK365FA4BB24B1D45C foreign key (lemon_id) references lemon (id);
> Some databases don't support enough characters for foreign key names to generate a readable foreign key name, so that's a sensible default.
> However, those of use that use databases like MySQL etc, would like a readable foreign key name, such as:
> alter table apple add index FK_Apple_lemon (lemon_id), add constraint FK365FA4BB24B1D45C foreign key (lemon_id) references lemon (id);
> We can do that by annotating every entity with @Index in JPA, or specifying it in a hbm file,
> but we can't do it generally, by extending DefaultNamingStrategy or ImprovedNamingStrategy.
> Here's a proposition on how we could do it:
> - In the NamingStrategy interface, next to the method foreignKeyColumnName, add a method:
> public String foreignKeyConstraintName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
> - DefaultNamingStrategy and ImprovedNamingStrategy should implement it as it is now, based on hashcodes.
> - If a mapping has an @Index JPA annotation or it's specified in a hbm file, that override counts.
--
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