[ https://issues.apache.org/activemq/browse/CAMEL-2980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=60839#action_60839 ]
Christian Mueller commented on CAMEL-2980: ------------------------------------------ I modified in my workspace the [JpaTest.java|http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java?view=markup]. old: {code} template.send(endpoint, new Processor() { public void process(Exchange exchange) { exchange.getIn().setBody(new SendEmail("f...@bar.com")); } }); {code} new: {code} Exchange returnedExchange = template.send(endpoint, new Processor() { public void process(Exchange exchange) { exchange.getIn().setBody(new SendEmail("f...@bar.com")); } }); SendEmail sendEmail = returnedExchange.getIn().getBody(SendEmail.class); assertEquals("address property", "f...@bar.com", sendEmail.getAddress()); assertNotNull("id property should set", sendEmail.getId()); {code} This fails with: {code} java.lang.AssertionError: id property should set at org.junit.Assert.fail(Assert.java:91) ... {code} After switching from EntityManager.merge(entity) to EntityManager.persist(entity), the test succeed. Because of this and [CAMEL-2982|https://issues.apache.org/activemq/browse/CAMEL-2982], my question is: "Should we in general switch from EntityManager.merge(entity) to EntityManager.persist(entity)?" Is there a reason to use EntityManager.merge(entity)? Christian > camel-jpa doesn't use EntityManager.merge(entity) in the right way > ------------------------------------------------------------------ > > Key: CAMEL-2980 > URL: https://issues.apache.org/activemq/browse/CAMEL-2980 > Project: Apache Camel > Issue Type: Bug > Components: camel-jpa > Affects Versions: 2.4.0 > Environment: All > Reporter: Christian Mueller > Assignee: Christian Mueller > Fix For: 2.5.0 > > > The EntityManager.merge(entity) method returns the merged entity. The > exchange in message body should be updated with the merged entity (what > camel-jpa currently not do). > I running into this problem, because after saving an entity in the database, > the id field was still null. So, we don't know, which entity in the database > is the corresponding to this entity... :-( > Have a look in the process method of > [JpaProducer|http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java?view=markup] > and the Java doc from the > [EntityManager|http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/javax/persistence/EntityManager.html#merge%28T%29]. > Christian -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.