2 Replies Latest reply on Mar 24, 2009 2:25 PM by tszpinda

    OrderBy for collection

    tszpinda

      Hi guys,


      I'm try to sort a collection, something like @OrderBy(product.description), but it does not work.


      Could you at the sample below and see what I'm doing wrong,


      public class Product{
          @Id
          private String code;
          private String description;
      }
      
      public class OrderLine{   
          @ManyToOne(fetch\=FetchType.LAZY)
          @JoinColumn(name\=product_code,referencedColumnName\=code, nullable\=false)
          private Stock stock;
      }
      
      public class Order{
      
          @OrderBy(product.description)
          @OneToMany(mappedBy\=order, cascade\={CascadeType.ALL})
          private List\<OrderLine\> orderLines;
      
      }
      



      Above code throws exception:
      org.hibernate.AnnotationException: property from @OrderBy clause not found: com.ylem.model.webshop.OrderLine.stock.description



      If I change @OrderBy(product.description) to @OrderBy(product) it does not throw the exception but it does not sort as I like.


      Any ideas?


      Thanks in advance


      Tomek