Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Bean Validation with Callback Methods - Spec Violation?

I haven't gotten a reply on this topic yet, any insight would be greatly helpful. 

On Tue, Jan 26, 2016 at 2:24 PM, Dalia Abo Sheasha <daliasheasha@xxxxxxxxx> wrote:

I am running a test where an entity has a constraint and contains a preUpdate callback method similar to the following:

public class Entity1 {
    private String name;


    protected void preUpdate() {
        preUpdateCalled = true;

My test tries to insert a null into the variable "name" then tries to persist the entity. As expected, a ConstraintViolationException is thrown. However, my preUpdate method does not get called before the exception is thrown. Is this behavior valid? If I am reading the spec correctly, it seems like validation should be happening after my preUpdate method is called. Here is the JPA 2.1 spec section that I am looking at:

3.6.1 Automatic Validation Upon Lifecycle Events
This specification supports the use of bean validation for the automatic validation of entities upon the pre-persist, pre-update, and pre-remove lifecycle validation events. These lifecycle validation events occur immediately after the point at which all the PrePersist, PreUpdate, and PreRemove lifecycle callback method invocations respectively have been completed, or immediately after the point at which such lifecycle callback methods would have been completed (in the event that such callback methods are not present).

Am I missing something or is this a bug in EclipseLink?



Back to the top