[
https://issues.apache.org/jira/browse/OPENJPA-1787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004237#comment-13004237
]
Michael Dick commented on OPENJPA-1787:
---------------------------------------
The main problem with your proposed solution is that it would change the way
merge works. EntityManager.merge creates a new copy of the entity and it's the
copy of the entity that becomes part of the persistence context - not the
entity you passed in. Your change would eliminate the copy.
I think the real issue here is that the data hasn't been copied into the new
instance before validation occurs. I'm not familiar with this code path, and I
haven't had a chance to try your testcase yet, but I'd start by looking at the
code where we copy the fields into a new instance.
> Bean validation fails merging a new entity
> ------------------------------------------
>
> Key: OPENJPA-1787
> URL: https://issues.apache.org/jira/browse/OPENJPA-1787
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa, kernel
> Affects Versions: 2.0.1, 2.1.0, 2.2.0
> Reporter: Oliver Ringel
> Priority: Critical
> Attachments: com.example.TestEmployeeDAO.txt, openjpa-1787.tar,
> testcase-openjpa-1787.tar
>
>
> The bean validation is not working correctly
> If you try to merge a new entity.
> EntityManager em = entityManagerFactory.createEntityManager();
> Person person = new Person();
> person.setName("Oliver"); //
> Employee.name is annotated @NotNull
> person = em.merge(person);
> you get a ConstraintValidationException, although name is set.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira