[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-959?page=co...
]
Dan Allen commented on HBX-959:
-------------------------------
I now agree with this rejection. The correct answer is that to override a foreign key
constraint, the constraint name is REQUIRED. You can create new foreign key associations
that are not specified in the database by using the column-ref element, but to change the
semantics of an existing foreign key, you (only) have to specify the constraint name. With
that in place, it works beautifully!
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira