Farrukh Najmi wrote:
>
> I need to implement row level access control and authorization within
> my JPA client application.
> I wanted to confirm that I can use the following methods to intercept
> the db transaction
> before it is committed:
>
> * PrePersist
> * PreRemove
> * PreUpdate
>
> and place my access control and authorization checks there. If the
> action is denied and an AuthorizationException is thrown in the
> callback methods can I assume that the commit would fail with some
> exception that has my exception as the nested exception / cause?
>
> The spec seems to be silent on this point but I can't imagine any
> other possibility for implementations to take.
>
Apparently the spec does state this quite clearly. I just missed it:
"Lifecycle callback methods may throw unchecked/runtime exceptions. A
runtime exception
thrown by a callback method that executes within a transaction causes
that transaction to be
rolled back."
So I believe things SHOULD work as expected. Thanks.
--
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com