| Just some background on the internals of this of what happens in GORM. In GORM we implement a `PreInsertEventListener` which defines a method `public boolean onPreInsert(PreInsertEvent event)` with the description: "Return true if the operation should be vetoed" If however `true` is returned to veto the operation then this leads to Hibernate throwing a `NullPointerException`. The reason for the bug is the `makeEntityManaged` which still attempts to make the entity managed even if the insert operation has been vetoed here: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java#L123 The `makeEntityManaged` method is called from: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java#L286 The fix should be that the entity does not become managed if the `PreInsertOperation` is vetoed. |