PostLoad method is not being called on an Id class
I have an entity class and another class is Identity class of this entity. I have written @javax.persistence.PostLoad annotation in Id class to put some default value on one of the column.
But I found out that it is not being called at all. Is it that ID classes should not have this 开发者_运维百科annotation?
you can annotate a method in you Entity class by @PostLoad to set default value to ...
if you annotate you ID class, then you need to introduce it as Callback Listener in your Entity class :
@EntityListeners({ID.class})
class MyEntity
and i don't think its a good idea, because the instance of your Listener is not related to the Instance of ID in your Entity class. they are 2 different object of ID class.
@PostLoad
Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to methods of an entity class, a mapped superclass, or a callback listener class.
精彩评论