ObjectDB ObjectDB

Populating entity id before transaction commit

#1

Hi,

I have a question about populating auto generated id before transaction commit. We are using OBD with Spring and transactions are managed by Spring. The problem is, that we have custom annotation that wraps some of those functions to do additional work. But this annotation is executed before transaction is committed so all returned entities are not populated with ID in this context. How can I force ODB to populate entity ID before transaction is committed? Or maybe there is another way to finding ID of entity before commit?

edit
delete
#2

You can use a SEQUENCE (or TABLE) value generation strategy and IDs would be set on persist rather than on commit.

Alternatively you can force early auto ID setting by:

Object id = emf.getPersistenceUnitUtil().getIdentifier();

 

ObjectDB Support
edit
delete
#3

We are using 'Auto' strategy right now, so I have to change our strategy to sequence or table or I will try to force setting id.

Thanks.

edit
delete

Reply

To post on this website please sign in.