Hibernate Tips: How to automatically set an attribute before persisting it

Hibernate Tips: How to automatically set an attribute before persisting it

Hibernate Tips is a new series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question you like me to answer, please leave a comment below. Question: I want to initialize an entity attribute automatically before it gets persisted. How can I execute custom code…