Hi,
I have been searching the manual, examples, and mail lists for an
implementation of a List, where the items in the list are positional stable
after the commit.  I¹ve had no luck and I am now wondering if it exists.  I
imagine it would need to otherwise nobody could properly store an ArrayList
using OpenJPA!  (should be basic stuff) Hibernate does this using
<list-index column="position"/>

Here¹s the problem.  Let¹s say I have a contrived Book object which has a
List (ArrayList) of pages (Page objects).  The pages in the List need to
maintain their order. Page 1,2,3,4 etc.  The order is maintained by using a
position or sequence number which is used to sort the list.

The db scheme would be something like

Create table book (
    book_id number,
    title varchar
)

Create table page (
    page_id number,
    page_data clob
)

And here¹s the link table

Create table book_page (
    book_id number,
    page_id number,
    sequence number  <<<<--- the position or sequence number 1,2,3,4,5,etc
) -- all not null

The Collection annotations for List need to automatically insert and update
the sequence numbers to make the ArrayList maintain stable order upon
commits.  The sequence needs to be incremented and decremented for List adds
and removes and renumbered for mid-list insertions and removes.

Does anyone know how to implement this in OpenJPA?  Is it supported?  It¹s
really just maps a java List to a db schema, keeping the list items order
stable during persistence.

Thanks,
Kevin

Reply via email to