lifesycle management via annotations would be handy
Quite right. At the moment you have to use the Ebean specific BeanPersistController.
However, the BeanPersistController does do more ... takes into account partial objects (loaded properties), gives you access to the transaction and server that is processing the persist request etc, allows you to override the insert/update/delete behaviour.
Also note that often @PostPersist is NOT what you want as that fires even when a transaction rolls back - in this case you'd want to use a BeanPersistListener instead.
So yes, we need to add support for the annotations... but be careful because sometimes you might need to use a BeanPersistController or BeanPersistListener instead.
For people using partial objects then the @Pre* @Post* annotations in JPA are not going to be very good.
Specifically, most of the time you are going to also need to know which properties where loaded or updated etc.
It is not clear to me people understand this (and just use the @Pre* @Post* annotations and end up having problems).
Well, I have a particular use case where I need to do some action when object loads - de-serializing some (@Transient) fields stored in a single database field. This can be done with BeanPersistListener indeed (and this is the way we currently do it) but @PostLoad on a class method would encapsulate class code better.
I blogged about this and included a solution:
Good work there.
What I have been thinking about is using a thread local so that the BeanPersistRequest and its associated information is available if/when people need it.
I'd also need to do something similar for PostLoad.
// for pre- post- insert, update, delete
// for pre- post- update
// for post load
That way people can use the annotations and not fall into a hole.