[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4479?page=c...
]
Paul Benedict commented on HHH-4479:
------------------------------------
Let's take a step back and make a differentiation here. There's a difference
between supporting legacy behavior and how it is accomplished. Translating legacy behavior
from HBM files to annotations doesn't mean it's a black-and-white mechanical
translation. In fact, how could it be? Converting mapping files to annotations is a task
in itself, and not even the attributes are identical. Therefore, making
referencedColumnName mandatory with a formula-joins seems like such a small price to pay
when making the jump to annotation-based configuration. Rhetorically speaking, what's
the problem with saying joins must be name-based when using annotations? If someone needs
to do positional-based joins, HBM (i.e., legacy) files are there for them.
About your second point, Java does not allow annotations to be repeated. Only one type may
be annotated per target, or otherwise you have to use a container (like @JoinColumns) that
accepts an array. Here's an expanded example:
@ManyToOne
@JoinColumn(name="order_nbr", referencedColumnName="order_nbr")
@JoinFormulas({
@JoinFormula(value="'true'",
referencedColumnName="is_default"),
@JoinFormula(value="'true'",
referencedColumnName="is_personalized")
})
public Menu getOrder() {
return order;
}
We should be able to implement Joins using formulas with Annotations
---------------------------------------------------------------------
Key: HHH-4479
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4479
Project: Hibernate Core
Issue Type: New Feature
Components: annotations
Reporter: Sharath Reddy
Assignee: Sharath Reddy
Priority: Minor
Fix For: 3.5
Attachments: HHH-4479.patch, HHH-4479second.patch
This article published on the O'Reilly web site -
http://onjava.com/pub/a/onjava/2005/08/03/hibernate.html?page=3 - describes how to
implement joins with formulas, using the hbm xml files. We should be able to do the same
with annotations:
<hibernate-mapping>
<class name="Company" table="Company">
<id name="id" />
<many-to-one
name="defaultContactPerson"
property-ref="defaultContactPerson">
<column name="id"/>
<formula>1</formula>
</many-to-one>
</class>
<class name="Person" >
<id name="id" />
<properties name="defaultContactPerson">
<property name="companyID" />
<property name="defaultFlag" />
</properties>
</class>
</hibernate-mapping>
--
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