[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-401) @OrderBy does not work with inherited properties

Dave Whittaker (JIRA) noreply at atlassian.com
Wed Jan 30 16:09:55 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29431 ] 

Dave Whittaker commented on ANN-401:
------------------------------------

I'm curious as to why this would be so difficult.  Could one not just check the metadata for the target object to see where the order by property is within the class hierarchy and then do an additional join to the table that represents the targets superclass?  Ok, that was clearer in my head than it sounds when I re-read it.  Basically, using the example above (with joined inheritance) why can't the location of propertyForOrderBy by determined to be class A (I'm assuming Hibernate already has this information available), which could result in the table for class A being joined during the query using the primary keys of A and B, then the order by would simply have to reference the table for A.  Or am I completely off here....... 

> @OrderBy does not work with inherited properties
> ------------------------------------------------
>
>                 Key: ANN-401
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-401
>             Project: Hibernate Annotations
>          Issue Type: Bug
>          Components: binder
>    Affects Versions: 3.2.0.cr1
>         Environment: Hibernate 3.2, MySql 4, Windows XP
>            Reporter: Guido Laures
>
> Using an @OrderBy with an inherited property produces an SQL Exception.
> Example:
> @Entity
> class Base {
>   ...
>   public int getPropertyForOrderBy(){ return propertytoOrderBy; }
>   ...
> }
> @Entity
> @PrimaryKeyJoinColumn(name="a_id")
> class A extends Base {
>    ...
> }
> @Entity
> @PrimaryKeyJoinColumn(name="b_id")
> class B extends Base {
>   ...
>     @OneToMany(mappedBy = "someProp", cascade = { CascadeType.ALL })
>     @OrderBy("propertyToOrderBy")
>     public Set<A> getASet() {
>         return this.aSet;
>     }
>   ...
> }
> Thus, if A references a set of Bs and wants it to be ordered by a property of B's base class Base it crashes. The generated SQL string tries to find the property from the base class in the table of the inerited class (A) which fails.

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