[hibernate-dev] Quick question about PostCommitInsertEventListener

Emmanuel Bernard emmanuel at hibernate.org
Tue Apr 28 12:04:23 EDT 2015


Hi,

I think a post-commit-insert event listener would be the best for you from what I have looked at.

Emmanuel

> On 27 Apr 2015, at 21:38, Haswell, Josiah D <Josiah.Haswell at ca.com> wrote:
> 
> 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
> 
> 
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list