[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4479?page=c...
]
Sharath Reddy commented on HHH-4479:
------------------------------------
Hi Paul,
As Emmanuel commented here
(
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4382) :
'My idea was to have a
@JoinColumnOrFormulas
which contains an array of
@JoinColumnOrFormula(
joinColumn=@JoinColumn, formula=@Formula
)'
The rationale behind that is to be able to keep the column ordering even if formula and
columns are mix and matched.'
Example:
@ManyToOne
@JoinColumnsOrFormulas(
{
@JoinColumnOrFormula(column=@JoinColumn(name="order_nbr",
referencedColumnName="order_nbr")),
@JoinColumnOrFormula(formula=@JoinFormula(value="'true'",
referencedColumnName="is_default"))
})
public Menu getOrder() {
return order;
}
@JoinColumns is part of the Java Persistence API, and @JoinFormula is a Hibernate
vendor-specific extension to the JPA standard. I believe we can't mix-and-match them.
If you want to discuss this in more detail, we can get together on chat or something....
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