You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Benjamin Runnels (JIRA)" <ji...@apache.org> on 2017/05/05 11:47:04 UTC
[jira] [Commented] (OLINGO-546) Cannot create entities with
composite key using EmbeddedId annotation
[ https://issues.apache.org/jira/browse/OLINGO-546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15998209#comment-15998209 ]
Benjamin Runnels commented on OLINGO-546:
-----------------------------------------
I am experiencing this same issue with olingo 2.0.7. Were you able to resolve it or only workaround by using idClass?
> Cannot create entities with composite key using EmbeddedId annotation
> ---------------------------------------------------------------------
>
> Key: OLINGO-546
> URL: https://issues.apache.org/jira/browse/OLINGO-546
> Project: Olingo
> Issue Type: Bug
> Components: odata2-jpa
> Affects Versions: V2 2.0.1
> Environment: Windows 7, Apache Tomcat 7.0.56
> Reporter: Riccardo
> Assignee: Chandan V.A
> Priority: Critical
>
> Hi,
> I've some problems when i create entities with composite key using EmbeddedId annotation. Below there are the classes causing the issue
> {code:title=TestTable.java|borderStyle=solid}
> @Entity
> @Table(name="TEST_TABLE")
> public class TestTable implements Serializable {
> private static final long serialVersionUID = 1L;
> @EmbeddedId
> private TestTablePK id;
> @Column(name="COL_GENERIC", length=20)
> private String colGeneric;
> public TestTable() {
> }
> public TestTablePK getId() {
> return this.id;
> }
> public void setId(TestTablePK id) {
> this.id = id;
> }
> public String getColGeneric() {
> return this.colGeneric;
> }
> public void setColGeneric(String colGeneric) {
> this.colGeneric = colGeneric;
> }
> }
> {code}
> {code:title=TestTablePK.java|borderStyle=solid}
> @Embeddable
> public class TestTablePK implements Serializable {
> private static final long serialVersionUID = 1L;
> @Column(name="COL_KEY1", unique=true, nullable=false)
> private int colKey1;
> @Column(name="COL_KEY2", unique=true, nullable=false)
> private int colKey2;
> public TestTablePK() {
> }
> public int getColKey1() {
> return this.colKey1;
> }
> public void setColKey1(int colKey1) {
> this.colKey1 = colKey1;
> }
> public int getColKey2() {
> return this.colKey2;
> }
> public void setColKey2(int colKey2) {
> this.colKey2 = colKey2;
> }
> public boolean equals(Object other) {
> if (this == other) {
> return true;
> }
> if (!(other instanceof TestTablePK)) {
> return false;
> }
> TestTablePK castOther = (TestTablePK)other;
> return
> (this.colKey1 == castOther.colKey1)
> && (this.colKey2 == castOther.colKey2);
> }
> public int hashCode() {
> final int prime = 31;
> int hash = 17;
> hash = hash * prime + this.colKey1;
> hash = hash * prime + this.colKey2;
> return hash;
> }
> }
> {code}
> When i get the $metadata, the application thrown the following exception
> {color:red}
> java.lang.NullPointerException
> at org.apache.olingo.odata2.jpa.processor.core.access.model.JPAEdmMappingModelService.searchJPAEmbeddableTypeMapType(JPAEdmMappingModelService.java:196)
> at org.apache.olingo.odata2.jpa.processor.core.access.model.JPAEdmMappingModelService.checkExclusionOfJPAEmbeddableType(JPAEdmMappingModelService.java:238)
> at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmComplexType$JPAEdmComplexTypeBuilder.isExcluded(JPAEdmComplexType.java:260)
> at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmComplexType$JPAEdmComplexTypeBuilder.build(JPAEdmComplexType.java:239)
> at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmSchema$JPAEdmSchemaBuilder.build(JPAEdmSchema.java:116)
> at org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmModel$JPAEdmModelBuilder.build(JPAEdmModel.java:61)
> at org.apache.olingo.odata2.jpa.processor.core.edm.ODataJPAEdmProvider.getSchemas(ODataJPAEdmProvider.java:282)
> at org.apache.olingo.odata2.core.edm.provider.EdmServiceMetadataImplProv.getDataServiceVersion(EdmServiceMetadataImplProv.java:102)
> at org.apache.olingo.odata2.api.processor.ODataSingleProcessor.readMetadata(ODataSingleProcessor.java:378)
> at org.apache.olingo.odata2.core.Dispatcher.dispatch(Dispatcher.java:182)
> at org.apache.olingo.odata2.core.ODataRequestHandler.handle(ODataRequestHandler.java:129)
> at org.apache.olingo.odata2.core.rest.ODataSubLocator.handle(ODataSubLocator.java:167)
> at org.apache.olingo.odata2.core.rest.ODataSubLocator.handleGet(ODataSubLocator.java:58)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:198)
> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:261)
> at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:100)
> at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
> at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
> at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
> at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
> at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
> at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
> at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208)
> at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:271)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
> at org.wso2.carbon.sample.tomcat.valve.samlsso.SAMLSSOValve.invoke(SAMLSSOValve.java:38)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:744)
> {color}
>
> doing debugging i've seen that the field jpaEmbeddableTypes of the object JPAPersistenceUnitMapType is null causing the NullPointerException.
> This issue is not occur if i use the jpa annotation idClass instead of EmbeddedId.
> Could you help me please?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)