[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4479) We should be able to implement Joins using formulas with Annotations

Paul Benedict (JIRA) noreply at atlassian.com
Sun Oct 11 16:16:43 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34147#action_34147 ] 

Paul Benedict commented on HHH-4479:
------------------------------------

Sharath, thank you for explaining. I gathered myself too it was because you wanted to preserve column ordering, but why is it important to keep? I do ask that seriously :-) All the information to link up relationships exist in @JoinColumn(name=, referencedColumnName=). As long as the referenced column names are specified, the order isn't important. 

Let me redo your example to demonstrate:
@ManyToOne
@JoinColumn(name="order_nbr", referencedColumnName="order_nbr")
@JoinFormula(value="'true'", referencedColumnName="is_default")
public Menu getOrder() {
    return order;
} 

Because the referencedColumnNames attributes are present, the SQL should end up as:
...WHERE _reftable.order_nbr = this.order_nbr and _reftable.is_default = 'true'

Because Joins are name-based, not positional-based, that's why I think we can mix-and-match. When possible, join columns should remain JPA-pure and allow Hibernate's extensions to add on top.. Your patch is great, but I think it farther than necessary to make the feature work. Does this make sense to you?

> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list