Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Maintain Insert order while inserting in a table
Maintain Insert order while inserting in a table [message #991698] Thu, 20 December 2012 02:16 Go to next message
Zaraki r is currently offline Zaraki rFriend
Messages: 2
Registered: March 2012
Junior Member
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

@Table(name = "entity")
@AttributeOverride(name = "id", column = @Column(name = "entityId"))
public class EntityA  {
    private static final long serialVersionUID = 2337915639426837746L;

    @Column(name = "name")
    protected String name;

    @OneToMany(mappedBy = "entity", fetch = FetchType.EAGER, cascade = CascadeType.ALL,orphanRemoval=true)
    private List<EntityB> setAssignmentEntities = new ArrayList<EntityB>();


@Table(name = "entity_set")
public  class EntityB implements Serializable {

    private static final long serialVersionUID = -7050818401379732731L;
            @JoinColumn(name = "entityId", referencedColumnName = "entityId", updatable = false, insertable = false) })
    EntityA entity;
    @Column(name = "entityName")
    private String entityName;

    @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

Now if I query the db I get the results in order

It is very important for our application that the original order is retained.
Is there any way to retain the order of the inserts?

Re: Maintain Insert order while inserting in a table [message #991927 is a reply to message #991698] Thu, 20 December 2012 13:54 Go to previous message
khalil haddad is currently offline khalil haddadFriend
Messages: 12
Registered: November 2012
Junior Member
You can take a look at this page :

It explains how to use the @OrderBy JPA 1.0 annotation.
Previous Topic:show_sql turn off at runtime
Next Topic:JAXB with Eclipse RCP
Goto Forum:

Current Time: Sun Jun 24 11:24:55 GMT 2018

Powered by FUDForum. Page generated in 0.02077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top