In JPA, can I access the field created by @OrderColumn in the assembled object?

My sample code is:

 public class A {

  @OneToMany
  @OrderColumn (name = "ORDER")
  private List <B> bList;
  ...
 }

 public class B {

  @Column (name = "ORDER")
  private Integer order; // I need this field because I want
                         // to use the ordering field in my query.
  ...
 }

Using this code, EclipseLink will try to create the "ORDER" column 2 times, throwing an exception and not creating table B.

Thank.

+5
source share
2 answers

Please register an error for this problem in EclipseLink.

You do not need a column for the query, you can use the JPQL INDEX index (bList) to query the order column.

EclipseLink DescriptorCustomizer QueryKey , .

+2

All Articles