[
https://issues.apache.org/jira/browse/OLINGO-770?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14739202#comment-14739202
]
Miguel commented on OLINGO-770:
-------------------------------
Hi Chandan
I could also replicate this in the olingo-odata2-jpa-processor-ref-web
application..
In this case the Exception is:
Could not match segment: 'Categorys(code='E1',id=1L)/materials'.
The payload: Exchange[Message: {code=E1, description=SOME DESCRIPTION, id=1}]
Steps to replicate:
1. Start up the olingo-odata2-jpa-processor-ref-web application.
2. Create the following uni test and run it
package mypackage;
import static org.junit.Assert.*;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.olingo2.Olingo2Component;
import org.apache.camel.component.olingo2.Olingo2Configuration;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SalesOrderProcessingTest {
private static Logger LOG =
LoggerFactory.getLogger(SalesOrderProcessingTest.class);
private static String serviceUri =
"http://localhost:8080/olingo-odata2-jpa-processor-ref-web/SalesOrderProcessing.svc";
public static final String APPLICATION_JSON =
"application/json;charset=utf-8";
public static final String APPLICATION_XML = "application/xml";
public static final String APPLICATION_ATOM_XML =
"application/atom+xml";
private static ProducerTemplate template;
private static CamelContext camelContext;
private static String contentType;
@BeforeClass
public static void beforeClass() throws Exception {
contentType = APPLICATION_ATOM_XML;
camelContext = new DefaultCamelContext();
final Olingo2Configuration configuration = new
Olingo2Configuration();
configuration.setServiceUri(serviceUri);
configuration.setContentType(contentType);
final Olingo2Component component = new
Olingo2Component(camelContext);
component.setConfiguration(configuration);
camelContext.addComponent("olingo2", component);
camelContext.setTracing(true);
camelContext.start();
template = camelContext.createProducerTemplate();
}
@AfterClass
public static void afterClass() throws Exception {
if (camelContext != null) camelContext.stop();
}
@Test
public void test() {
Map<String, Object> body = getCategoryData();
ODataEntry entry =
template.requestBody("olingo2://create/Categorys", body, ODataEntry.class);
}
public Map<String, Object> getCategoryData() {
Map<String, Object> data = new HashMap<String, Object>();
data.put("code", "E1");
data.put("id", 1);
data.put("description", "SOME DESCRIPTION");
return data;
}
}
It is supposed a Category can be added without any Material restriction..
right?? I mean.. it should not depend on the existence of a Material..right??
Cheers
Miguel
> JPA OneToMany not able to create entity
> ---------------------------------------
>
> Key: OLINGO-770
> URL: https://issues.apache.org/jira/browse/OLINGO-770
> Project: Olingo
> Issue Type: Bug
> Components: odata2-jpa
> Affects Versions: V2 2.0.4
> Reporter: Miguel
> Assignee: Chandan V.A
>
> I have 2 entities OrderHeader and OrderItem,, the relation between then is
> One To Many... with bi-directional
> In the OrderHeader
> @OneToMany(mappedBy="OrderHeader")
> private List<OrderItem> orderItems;
> In the OrderItem
> @ManyToOne(fetch=FetchType.LAZY)
> @JoinColumn(name="ORDER_ID", nullable=false)
> private OrderHeader orderHeader;
> When the following is called
> ODataEntry entry = template.requestBody("olingo2://create/OrderHeaders",
> body, ODataEntry.class);
> There is a exception thrown
> Could not match segment: 'OrderHeaders(4004280407L)/OrderItemDetails'.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)