« Return to Thread: Re: Sequence generator - as a service

Re: Sequence generator - as a service

by James Sutherland :: Rate this Message:

Reply to Author | View in Thread

So my understanding is that you want to assign the sequence numbers to your objects yourself, outside of the transaction where the objects are persisted.

You can do this in EclipseLink using the EclipseLink Session API getNextSequenceNumberValue(Class).  You will need to cast your JPA EntityManager to get the EclipseLink Session from it.

Jan Vissers wrote:
Let me try and clarify.

Basically I want to have an entity, say

  @Entity
  public class Master implements Serializable {
      @Id
      private long id;

      public void setId(long id) {
          this.id = id;
      }
  }

For which the primary key will be created separately - in the most
efficient way (like EclipseLink which caches a number of unique numbers
from a sequence) - in order to set it later. The creation of the key value
and the actual storage of the Master are not within the same persistency
context.

-J.

 « Return to Thread: Re: Sequence generator - as a service