Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » persist a collection in order
persist a collection in order [message #758564] Wed, 23 November 2011 12:00
FiruzzZ Mising name is currently offline FiruzzZ Mising name
Messages: 19
Registered: October 2011
Junior Member
Alo..
the issue is that when I persist a Order with a of List<Item> (OneToMany), Item's are persisten randomly without respect the order of the List.
Exam:

order.getItemList().add(item1);
order.getItemList().add(item2);
order.getItemList().add(item3);
persist(order);

When I retrieve (or check directly on the DB) the entity and check the detail, they are disordered.
Sometimes persist first item1, sometimes item2 and so on..

The only way i found to avoid this behavior was persist the Order with a empty collection and then one by one the collections of Item's.

here is fragment of the mapping

//on Order
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.EAGER)
private List<Item> itemList;
Previous Topic:Re: How can I check PersistenceContexts for equality
Next Topic:persist a collection in order
Goto Forum:
  


Current Time: Wed Jul 23 22:21:03 EDT 2014

Powered by FUDForum. Page generated in 0.01639 seconds