persist a collection in order [message #758564] |
Wed, 23 November 2011 17:00 |
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;
|
|
|
Powered by
FUDForum. Page generated in 0.03940 seconds