开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜