users@glassfish.java.net

Entity callbacks/listeners

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Tue, 6 Mar 2007 16:08:16 +0100

Hello,
in my application, I would like some entity beans to be locked for
changes if situation requires so. I have, for example, Proposal entity
with field locked : boolean.

I would like to guarantee that there is no possible way to modify that
entity if it is locked, but there must be some way to unlock it.

I was thinking, I could use @PrePersist callback event, but in that
method I can only check current state, for example I could throw an
exception if "locked" is true. But after applying that callback, there
will be no possible way to unlock that entity, as I cannot check if
"locked" new state is false...

I was thinking about checking that in SessonBean, but that would be
VERY easy to forget about that in some place (for example when adding
new functionality to application in future) and that could cause data
to become in inconsistent state :/

What are your suggestions? Is there some way to use entity
callbacks/listeners for my purpose?

Witold Szczerba