My target is that EJB should generate a sequence as it generates tables from Entities. How can I do that?
I thought about this, but in that case I only use an existing sequence. I'd like a sequence to be generated by JPA. I think this isn't possible, or is it?
@Entity
@Table(name = "CUSTOMER")
@SequenceGenerator(name = "sb_sequence",sequenceName = "sb_sequence", initialValue=5420)
public class Customer extends EntityBase
{
private static final long serialVersionUID = 3456353535358L;
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sb_sequence")
@Column(name = "CUS_SEQUENCE")
private long cusSequence;
.
.
.
}
Background: Before I insert the first value into database, I need to retrieve the first sequence number (probably with select nextval('sequence'); )