Bug 535998 - EL 2.6.4 OF WLS 12.2.1.2 DOES NOT PROPERLY IMPLEMENT JSR 303 ISSUE
Summary: EL 2.6.4 OF WLS 12.2.1.2 DOES NOT PROPERLY IMPLEMENT JSR 303 ISSUE
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-18 06:29 EDT by Sureshkumar Balakrishnannair CLA
Modified: 2022-06-09 10:08 EDT (History)
0 users

See Also:


Attachments
testcase (141.47 KB, application/x-zip-compressed)
2018-06-19 06:28 EDT, Sureshkumar Balakrishnannair CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sureshkumar Balakrishnannair CLA 2018-06-18 06:29:35 EDT
We are preparing our code to deploy in JEE7 WEBLOGIC 12.2.1.2 container.
We are changing our POMS to use the same library version that weblogic
12.2.1.2 uses to provided the different JEE standards.

In the case of JPA 2.1 weblogic seems to bundle eclipse link 2.6.4 version.
The most patch fixed version of eclipse link.

While validating integration tests for our application, we have verified
already two critical bugs in eclipse link code in terms of properly upholding
the usage of bean validations in its internal workflow.

Issue #1 ( see the bug request # 25237864).

Issue #2:
The BeanValidationListener class above only subscribes to events:
preUpdate,preRemove,prePersist.
This is clearly not sufficient.
Comment 1 Sureshkumar Balakrishnannair CLA 2018-06-18 06:31:02 EDT
 tried the re-producer attached , the points are [eclipse link version
2.6.4]

-@Test
public void placeboTest()
This test case is executing as expected , throwing
ConstraintViolationException

-demonstrateHowWeCanViolateBusinessRulesByFollowingADifferentFlow
This is failing , here we are using a different approach : - not creating new
Bug2Entity() object , we modify the already existing entity with invalid
scenario . So that breaks

Please confirm the points
Comment 2 Sureshkumar Balakrishnannair CLA 2018-06-18 06:31:26 EDT
Yes, points you have mentioned is true.

Customer's update:
But that is what this service request/Bug has been about from the start.
This thread is about the fact that when we:
1. em.perist(entity)
2. modify(entity) violation assertion rules
3. commit
we are able to commit the entity violation JPA constraint validations.
Comment 3 Sureshkumar Balakrishnannair CLA 2018-06-19 06:17:39 EDT
Problem summery 
-------------

Here the issue is direct persist works good , its throwing a ConstraintViolationException if any

Bug2Entity ageValidationEntity = new Bug2Entity();
        ageValidationEntity.setNotNullField("InThisTestTheNotNullFieldIsIrrelevantToUs");
        ageValidationEntity.setAge(ALLOWED_AGE);
        em.persist(ageValidationEntity);

but if we try to modify the persisted bean within the same transaction and  committed it is not checking constrained Violations  

	// (a) we start by calling persist on a fresh new entity thaat starts off being valid
        Bug2Entity ageValidationEntity = new Bug2Entity();
        ageValidationEntity.setNotNullField("InThisTestTheNotNullFieldIsIrrelevantToUs");
        ageValidationEntity.setAge(ALLOWED_AGE);
        em.persist(ageValidationEntity);

        // (b) now we demonstrate how eclipse link fails to invoke the JSR validations on entity
        // when we modify the entity during the transaction

        try {
            ageValidationEntity.setAge(NOT_ALLOWED_AGE);
            em.persist(ageValidationEntity);

above persist will work , it won’t check for constrained Violations  


Resolution/fix
------------- 
  
From the eclipse link code analysis we can see the unit of work is only triggering the call back events while registering a new bean 

Refer : public void registerNewObjectForPersist(Object newObject, Map visitedObjects)

Intern triggering the call back events in case of (registeredObject == null) 

While modifying  the persisted object the object won’t be null and eventually this wont sufficient to trigger the call backs 

So we added another condition which will handle the modification case , it will trigger the callbacks if any listeners associated with that entity
Comment 5 Sureshkumar Balakrishnannair CLA 2018-06-19 06:28:13 EDT
Created attachment 274532 [details]
testcase
Comment 6 Eclipse Genie CLA 2018-07-19 02:17:41 EDT
GitHub Pull Request 185 created by [sureshbn]
https://github.com/eclipse-ee4j/eclipselink/pull/185
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:05:18 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:08:06 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink