2014-06-18 33 views
0

我有以下问题:我的数据库中有一个使用一个定义类型的表:JPA - 无法插入到表一中定义的类型(Oracle)的

CREATE OR REPLACE TYPE ARRAY_METHODS IS VARRAY (10) OF NUMBER (2); 

此列被映射为List<BigDecimal>在其各自的实体。当我尝试使用JPA执行插入操作时,问题就开始了(我尝试了persist()merge())。寻找一个解决方案,我发现,我必须添加@Array@Struct注释:

@Entity 
@Struct(name="ARRAY_METHODS") 
@Table(name="MY_TABLE") 

... 

@Array(databaseType="ARRAY_METHODS") 
@Column(name="METHODS") 
private List<BigDecimal> methods; 

,但它仍然会失败:

Internal Exception: java.sql.SQLException: Unsupported Feature 
Error Code: 17023 
Query: InsertObjectQuery([email protected]) 
    at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1878) 
    at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:359) 
    at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:250)at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:336) 
    at weblogic.ejb.container.internal.BaseLocalObject.__WL_postInvokeTxRetry(BaseLocalObject.java:205) 
    at weblogic.ejb.container.internal.BaseWSLocalObject.__WL_postInvokeTxRetry(BaseWSLocalObject.java:194) 
    at weblogic.ejb.container.internal.WSOMethodInvoker.invoke(WSOMethodInvoker.java:40) 
    at com.myproject.ops.OpPhysicalResourcePortTypeImpl_14p9mm_WSOImpl.__WL_opAltaRecurso(Unknown Source) 
    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 weblogic.wsee.server.ejb.WsEjb.invoke(WsEjb.java:54) 
    at weblogic.wsee.jaxws.WLSEjbInstanceResolver$WLSEjbInvoker.invoke(WLSEjbInstanceResolver.java:196) 
    at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:91) 
    at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149) 
    at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88) 
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136) 
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050) 
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019) 
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877) 
    at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:420) 
    at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:687) 
    at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:266) 
    at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:169) 
    at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:205) 
    at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:634) 
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) 
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) 
    at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:108) 
    at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:278) 
    at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:287) 
    at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:134) 
    at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:844) 
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280) 
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254) 
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) 
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341) 
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238) 
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3363) 
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333) 
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) 
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) 
    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) 
    at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220) 
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146) 
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124) 
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564) 
    at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254) 
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295) 
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254) 
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.DatabaseException 

与合作:Oracle数据库11g快捷版,JDK 7的Oracle WebLogic 12c

感谢您的帮助。

回答

0

与Oracle联系后,他们说问题在于不允许插入数值数组。所以现在我们有一张新桌子。

0

在同一张桌子里是否至关重要?解决方案可以使用@ElementCollection代替@Array

+0

这并不重要,但我在这个项目中工作,我不能自由地改变模型。无论如何,感谢您的建议,但它仍然无法正常工作。 – Sergi

+0

顺便说一句,你在起诉EclipseLink 2.4.2,你有没有尝试过它的更新版本? –

+0

是的,2.5和相同的错误。使用'@ ElementCollection'现在我得到'引发:java.sql.SQLIntegrityConstraintViolationException:ORA-01400:不能在NULL(“SERGI”。“MY_TABLE”。“METHODS”)中插入NULL。看看查询,我发现该列没有出现在它中。 – Sergi

相关问题