5
votes

My sample code:

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

With this code EclipseLink try to create the "ORDER" column 2 times throwing an exception and don't create the B table.

Thanks.

2
why not define how you want to use the ordering in a query - DataNucleus
Simply like this: SELECT b FROM B b WHERE ... ORDER BY order - devmao
So do as James said ... use "ORDER BY INDEX(list)" - DataNucleus
I tried but don't work with EclipseLink - devmao

2 Answers

2
votes

Please log a bug for this issue on EclipseLink.

You should not need the column just for querying, you can use the JPQL INDEX(bList) to query the order column.

In EclipseLink you can also use a DescriptorCustomizer to define a QueryKey for any column to allow querying on it.