openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger Keays (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2279) Merge Validation Fails With Chained Constructor
Date Mon, 15 Oct 2012 18:28:03 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476332#comment-13476332
] 

Roger Keays commented on OPENJPA-2279:
--------------------------------------

This issue is very similar to OPENJPA-1787 which has been marked resolved.
                
> Merge Validation Fails With Chained Constructor
> -----------------------------------------------
>
>                 Key: OPENJPA-2279
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2279
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: validation
>    Affects Versions: 2.2.0
>         Environment: java 1.6
>            Reporter: Roger Keays
>         Attachments: openjpa-2279.tar.gz
>
>
> The following simple test fails
>    em.merge(new Customer("Park Lane");
> when there is a chained constructor and validation like this:
>     public Customer() {
>         this(null);
>     }
>     public Customer(String street) {
>         address = new Address();
>         address.street = street; // annotated @NotNull
>     }
> OpenJPA validation is calling the first constructor during merge or validation
> and is trying to validate an invalid object, even though the orginal WAS valid.
> The stacktrace is
> Caused by: javax.validation.ConstraintViolationException: A validation constraint failure
occurred for class "testcase.openjpa.Address".
> 	at org.apache.openjpa.persistence.validation.ValidatorImpl.validate(ValidatorImpl.java:282)
> 	at org.apache.openjpa.validation.ValidatingLifecycleEventManager.fireEvent(ValidatingLifecycleEventManager.java:123)
> 	at org.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(BrokerImpl.java:800)
> 	at org.apache.openjpa.kernel.BrokerImpl.persistInternal(BrokerImpl.java:2635)
> 	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2571)
> 	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2554)
> 	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2544)
> 	at org.apache.openjpa.kernel.SingleFieldManager.persist(SingleFieldManager.java:272)
> 	at org.apache.openjpa.kernel.StateManagerImpl.cascadePersist(StateManagerImpl.java:3045)
> 	at org.apache.openjpa.kernel.BrokerImpl.persistInternal(BrokerImpl.java:2670)
> 	at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2571)
> 	at org.apache.openjpa.kernel.AttachStrategy.persist(AttachStrategy.java:95)
> 	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:102)
> 	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:252)
> 	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:105)
> 	at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3474)
> 	at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1214)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:878)
> 	at testcase.openjpa.OpenJpaTest.testValidation(OpenJpaTest.java:20)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message