LaLuz 0 Newbie Poster

Hi,

I'm having a problem getting the auto generated ID immediately upon commit.

I have an entityBean mapping like this:

@GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_SETTLEMENT_TRANS")
	@SequenceGenerator(sequenceName="SEQ_SETTLEMENT_TRANS", name="SEQ_SETTLEMENT_TRANS")
	@Id @Column(name="SET_TRANS_ID")
	private long setTransId;

and I am trying to get the Id like this:

setEntityManager(PersistenceManager.getEntityManager());
            getEntityManager().getTransaction().begin();
            getEntityManager().persist(settlementTrans);
            getEntityManager().flush();
            getEntityManager().getTransaction().commit();
            System.out.println("ID :: "+settlementTrans.getSetTransId());

I'm using Oracle database and I created a sequence and a trigger for my table.
What seems to be happening is that the sequence is triggered twice giving me a different ID from what is saved in the database.

Example::
I would retrieve an ID = 10
and the object is saved in the database with an ID = 11;

Did I configured my entityBean the wrong way?

Thanks,

LaLuz