1 Reply Latest reply on Jul 22, 2005 2:55 AM by Emmanuel Bernard

    @OrderBy bogus ???

    Jens Elkner Apprentice

      Hmm, I'm just testing the @OrderBy annotation, but it seems, that it is bogus, right ?

      2005-07-21 14:32:09,804 WARN [ScannerThread:org.jboss.system.ServiceController:353] - Problem creating service jboss.j2ee:service=EJB3,module=foo.par
      org.hibernate.AnnotationException: property from @OrderBy clause not found: foo.entities.A_OrderLineItemAttribute.id
       at org.hibernate.cfg.annotations.CollectionBinder.buildOrderByClauseFromHql(CollectionBinder.java:509)
       at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:415)
      


      The code for reproduction:
      public class A_OrderLineItem {
       private int id;
       List<A_OrderLineItemAttribute> attrs;
      
       @Id(generate = GeneratorType.AUTO)
       @Column(name = "orders_products_id", nullable=false)
       public int getId() {
       return this.id;
       }
       public void setId(int id) {
       this.id = id;
       }
      
       @OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL, mappedBy="orderLineItem")
       @OrderBy("id ASC")
       public List<A_OrderLineItemAttribute> getAttributes() {
       return attrs;
       }
       public void setAttributes(List<A_OrderLineItemAttribute> attrs) {
       this.attrs = attrs;
       }
      // ...
      }
      
      public class A_OrderLineItemAttribute {
       private int id;
       private A_OrderLineItem orderLineItem;
      
       @Id(generate = GeneratorType.AUTO)
       @Column(name = "orders_products_attributes_id", nullable=false)
       public int getId() {
       return this.id;
       }
       public void setId(int id) {
       this.id = id;
       }
      
       @ManyToOne(fetch=FetchType.LAZY)
       @JoinColumn(name = "orders_products_id", nullable=false,
       referencedColumnName="orders_products_id")
       public A_OrderLineItem getOrderLineItem() {
       return this.orderLineItem;
       }
       public void setOrderLineItem(A_OrderLineItem item) {
       this.orderLineItem = item;
       }
      //...
      }