Hi,
Take a look at the OrderBy annotation, or the JPA 2.0 OrderColumn
annotation for the standard way to represent ordered collections.
Here's the description from 7.6.3 of the OpenJPA user's guide:
Relational databases do not guarantee that records are returned in
insertion order. If you want to make sure that your collection
elements are loaded in the same order they were in when last stored,
you must declare an order column. An order column can be declared
using OpenJPA's org.apache.openjpa.persistence.jdbc.OrderColumn
annotation or the JPA 2.0 javax.persistence.OrderColumn annotation or
order-column orm element as defined in Section 3, “ XML Schema ”.
OpenJPA's org.apache.openjpa.persistence.jdbc.OrderColumn annotation
has the following properties:
•
String name: Defaults to the name of the relationship property or
field of the entity or embeddable class + _ORDER. To use the JPA 1.0
default order column name ORDR, set the Section 5.7, “
openjpa.Compatibility ” option UseJPA2DefaultOrderColumnName to false.
•
boolean enabled
•
int precision
•
String columnDefinition
•
boolean insertable
•
boolean updatable
Order columns are always in the container table. You can explicitly
turn off ordering (if you have enabled it by default via your mapping
defaults) by setting the enabled property to false. All other
properties correspond exactly to the same-named properties on the
standard Column annotation, described in Section 3, “ Column ”.
Craig
On Dec 14, 2009, at 10:11 AM, KARR, DAVID (ATTCINW) wrote:
I have two entities with a one-to-many association from the first to
the
second, and the database uses a join-table to represent this
association. The join table also has a "SEQUENCE_NUM" column to
represent the required ordering of this element in the collection of
elements. I understand how to use "join-table" and "join-column" to
describe the basic relationship, but I don't see any way to specify
that
the collection should be ordered by a column value in the join table.
Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:[email protected]
P.S. A good JDO? O, Gasp!