[hibernate-dev] Quick question about PostCommitInsertEventListener

Haswell, Josiah D Josiah.Haswell at ca.com
Mon Apr 27 15:38:34 EDT 2015


Hi folks,


In Datomic, when you create an entity, you must give the entity a temporary ID before you insert it.  After the transaction completes, each entity in the transaction is given an actual persistence ID back from the database.  My initial approach was to generate the temporary identifier in the createTuple method of the IdentityColumnAwareGridDialect, and provide a customer persister implementation to handle it.  It occurred to me that it might be easier to just use a listener.  After a bit of fiddling around, I discovered that PostCommitInsertEventListener can (apparently) substitute out the ID at what appears to be the correct location.  From what I can tell, this both simplifies the code, and the generated ID seems to be propagated to everything correctly.  Is the custom persister the preferred way to do this?  Or should this work?  Is there a better place to perform that substitution?

Thanks!

Josiah




More information about the hibernate-dev mailing list