Hi,
This is a problem I am running into.
We are using eclipselink 2.3.2.
I am adding snippets of what our entities look like
@Entity
@Table(name = "entity")
@AttributeOverride(name = "id", column = @Column(name = "entityId"))
public class EntityA {
private static final long serialVersionUID = 2337915639426837746L;
@Basic
@Column(name = "name")
protected String name;
@OneToMany(mappedBy = "entity", fetch = FetchType.EAGER, cascade = CascadeType.ALL,orphanRemoval=true)
private List<EntityB> setAssignmentEntities = new ArrayList<EntityB>();
}
@Entity
@Table(name = "entity_set")
public class EntityB implements Serializable {
private static final long serialVersionUID = -7050818401379732731L;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "entityId", referencedColumnName = "entityId", updatable = false, insertable = false) })
EntityA entity;
@Id
@Column(name = "entityName")
private String entityName;
@Id
@Column(name = "fieldId")
private int fieldId;
}
We do not have any Order by clause, however upon querying the
db, it is seen that the inserts to the EntityB were made as if sorted on the
primary key(fieldId).
For ex, If I insert entities with fieldId's
53
2
7
Now if I query the db I get the results in order
2
7
53
It is very important for our application that the original order is retained.
Is there any way to retain the order of the inserts?
Thanks