[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-959) allow foreign key property name override

Dan Allen (JIRA) noreply at atlassian.com
Wed Jul 11 03:34:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27438 ] 

Dan Allen commented on HBX-959:
-------------------------------

I'm sorry, but your statement is just not true. I am working with an SVN trunk build of Hibernate Tools, and I am telling you that when you use the same foreign-key information (local and foreign names) it creates 2 associates in the resulting Java class, one with a "_1" appended to the end of it.

> allow foreign key property name override
> ----------------------------------------
>
>                 Key: HBX-959
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-959
>             Project: Hibernate Tools
>          Issue Type: Improvement
>          Components: hbm2java
>    Affects Versions: 3.2beta9, 3.2beta10
>            Reporter: Dan Allen
>            Priority: Minor
>   Original Estimate: 1 day
>  Remaining Estimate: 1 day
>
> Without any special settings, the hbm2java tool will assign the @ManyToOne property the same name as the target class. For instance, let's say you have an employee table. Each employee can have a manager, who is also an employee. The column name might be manager_id, but the hbm2java tool will name the property employee. In this case, it is desirable to override the name of the property to be manager instead of employee.  Currently, there is no way to do this if foreign keys are active on the table. It IS possible if foreign keys are NOT defined on the table since then the foreign-key element in *.reveng.xml comes into play. The problem comes when you try to override the foreign-key, it just ends up created TWO @ManyToOne properties.
> What I am looking for (in hypothetical) is:
> <column name="manager_id" property="manager" />
> Obviously, that syntax only works for basic types, not associations. There needs to be way to override the foreign-key settings WITHOUT creating a new foreign key relationship. The location in the code where the property name is decided is JDBCBinder#bindOutgoingForeignKeys() which then delegates to ReverseEngineeringStrategy#revengStrategy.foreignKeyToEntityName()

-- 
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