سؤال

I have a field in my Entity with a One-to-Many relationship like so:

private List> entityB = new ArrayList>();

Let's say I have added entityB1 and entityB2 to the list. I can persist and retrieve the data and everything is fine.

However, let's say I later reorder the list, so it's entityB2 then entityB1. I persist the object again, but when I retrieve the object back, it turned back into the original order.

How do I ensure the order of the list is persisted?

هل كانت مفيدة؟

المحلول

It should come back in the order last saved. With the exception of Text and Blob types (GAE behavior), List contents are not reordered. You'll need to post more code to find out exactly what is going on - possibly you are querying for the object and seeing its eventually consistent (stale) state.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top