JPA 2.0 空值在刷新操作时从映射的超类继承的字段



我有以下层次结构

@MappedSuperclass
public class MensajeErrorBase{
@Enumerated(EnumType.STRING)
@Column(name = "SEVERIDAD", nullable = false, length = 50)
protected EnumSeveridadMensaje severidad;
//...
}
@Entity
@Table(name = "TRA_INGRE_IDENTI_MSJ")
public class IngresoPorIdentificarMsg extends MensajeErrorBase implements    Serializable, MensajeMonitoreo {
private static final long serialVersionUID = -8722933693750515329L;
@EmbeddedId
protected IngresoPorIdentificarMsgPK pk;
//...
}

以及我执行 crud 操作的跨 ejb。在另一个名为 ServicioProceso 的 ejb 中,我有以下方法:

private <T extends MensajeErrorBase> void guardarMensajesError(Class<T> claseEntidad, Serializable pk, List<T> listaMensajes,
                DatoSesionAud dsa) {
            try {
                MensajeMonitoreo msjMonitoreo = (MensajeMonitoreo) claseEntidad.newInstance();
                if (msjMonitoreo.getClaseMsjParam() == null) {
                    throw new RuntimeException(excepcionNosePropago(ServicioProceso.class, "guardarMensajesError",
                            "No estan configurados los metodos que retornan las clases de parametros en la clase de Mensajes Base"));
                }
                for (MensajeErrorBase mensajeErrorBase : listaMensajes) {
                    msjMonitoreo = (MensajeMonitoreo) mensajeErrorBase;
                    msjMonitoreo.setClavePrimaria((Serializable) BeansUtil.deepClone(pk));
                    super.insertSecuencia(msjMonitoreo, dsa);
                    List<MensajeErrorParamBase> listaMensajesParam = ((MensajeMonitoreo) mensajeErrorBase).getParametros();
                    for (int i = 1; i <= listaMensajesParam.size(); i++) {
                        MensajeMonitoreoParam msjMonitoreoParam = (MensajeMonitoreoParam) listaMensajesParam.get(i - 1);
                        msjMonitoreoParam.setClavePrimaria((Serializable) BeansUtil.deepClone(msjMonitoreo.getPk()), i);
                        super.insert(msjMonitoreoParam, dsa);
                        List<MensajeErrorParamParamBase> listaMensajesParamParam =
                                ((MensajeMonitoreoParam) listaMensajesParam.get(i - 1)).getParametros();
                        for (int j = 1; j <= listaMensajesParamParam.size(); j++) {
                            MensajeMonitoreoParamParam msjMonitoreoParamParam =
                                    (MensajeMonitoreoParamParam) listaMensajesParamParam.get(j - 1);
                            msjMonitoreoParamParam.setClavePrimaria((Serializable) BeansUtil.deepClone(msjMonitoreoParam.getPk()), j);
                            super.insert(msjMonitoreoParamParam, dsa);
                        }
                    }
                    super.flush();
                }
            } catch (InstantiationException | IllegalAccessException e) {
                LoggerUtil.runtimeException(e, ServicioProceso.class);
                throw new RuntimeException(excepcionNosePropago(ServicioProceso.class, "guardarMensajesError", e));
            }
        }

其中行:

 super.insertSecuencia(msjMonitoreo, dsa);

调用执行 crud 操作的 EJB 并发送对象 msjMonitoreo,其中包含来自映射超类和子类设置的所有数据。 但在同花顺调用中,我得到以下异常:

[4/5/17 10:52:05:995 ECT] 00000093 SystemOut     O [EL Warning]: 2017-04-05 10:52:05.994--UnitOfWork(-1281205041)--Thread(Thread[WebContainer : 3,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")
Error Code: 1400
Call: INSERT INTO TRA_INGRE_IDENTI_MSJ (ETIQUETA, RECURSO_MULTILENGUAJE, SEVERIDAD, COD_EMPRESA, SECUENCIA, NUM_LICENCIA, SEC_MENSAJE) VALUES (?, ?, ?, ?, ?, ?, ?)
        bind => [null, null, null, E-MPR, 1, 1, 4]
Query: InsertObjectQuery(IngresoPorIdentificarMsg[pk=IngresoPorIdentificarMsgPK[ numLicencia=1,codigoEmpresa=E-MPR,codigoProducto=1,secuenciaMensaje=4]])
[4/5/17 10:52:05:996 ECT] 00000093 BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "registrarMensajesError" on bean "BeanId(GestorG5#G5Core-ejb.jar#ServicioProceso, null)". Exception data: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")
Error Code: 1400
Call: INSERT INTO TRA_INGRE_IDENTI_MSJ (ETIQUETA, RECURSO_MULTILENGUAJE, SEVERIDAD, COD_EMPRESA, SECUENCIA, NUM_LICENCIA, SEC_MENSAJE) VALUES (?, ?, ?, ?, ?, ?, ?)
        bind => [null, null, null, E-MPR, 1, 1, 4]
Query: InsertObjectQuery(IngresoPorIdentificarMsg[pk=IngresoPorIdentificarMsgPK[ numLicencia=1,codigoEmpresa=E-MPR,codigoProducto=1,secuenciaMensaje=4]])
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:868)
        at com.ibm.ws.jpa.management.JPATxEmInvocation.flush(JPATxEmInvocation.java:255)
        at com.ibm.ws.jpa.management.JPAEntityManager.flush(JPAEntityManager.java:221)
        at com.gestorinc.gestor.crud.impl.CrudServiceImpl.flush(CrudServiceImpl.java:730)
        at com.gestorinc.g5.servicio.impl.general.ServicioProceso.guardarMensajesError(ServicioProceso.java:305)
        at com.gestorinc.g5.servicio.impl.general.ServicioProceso.registrarMensajesError(ServicioProceso.java:115)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:5730)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)
        at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callInterceptorsAndDecorators(OpenWebBeansEjbInterceptor.java:526)
        at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callToOwbInterceptors(OpenWebBeansEjbInterceptor.java:200)
        at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
        at org.apache.webbeans.ejb.WSEJBInterceptor.callToOwbInterceptors(WSEJBInterceptor.java:136)
        at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)
        at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:5621)
        at com.gestorinc.g5.servicio.impl.general.EJSLocalNSLServicioProceso_bf34d3b4.registrarMensajesError(EJSLocalNSLServicioProceso_bf34d3b4.java)
        at com.gestorinc.g5web.bean.bpm.TareasActividadesBandejaBean.ejecutarErrores(TareasActividadesBandejaBean.java:251)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at org.apache.webbeans.intercept.InterceptorHandler.invoke(InterceptorHandler.java:297)
        at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:98)
        at com.gestorinc.g5web.bean.bpm.TareasActividadesBandejaBean_$$_javassist_6.ejecutarErrores(TareasActividadesBandejaBean_$$_javassist_6.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:268)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
        at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:78)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:360)
        at javax.faces.component.UICommand.broadcast(UICommand.java:103)
        at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:119)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
        at com.gestorinc.g5web.filter.FiltroAccesoAutenticado.doFilter(FiltroAccesoAutenticado.java:76)
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
        at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)
        at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
        at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")

当我调试时,所有字段都设置了 de 相应的值。调试显示已设置所有字段。我的服务器运行在 WebSphere Application Server (Full( 8.5.5.0 上。但是当我部署到 Liberty WebSphere 时,它可以正常工作

这不是

双重persistence.xml它是一个玻璃鱼虫:

https://github.com/javaee/glassfish/issues/16164

我不得不禁用编织:

<properties>
  <!-- Documentation https://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm says its 'eclipse.weaving', but examples say its 'eclipselink.weaving'. Great. -->
  <property name="eclipselink.weaving" value="false"/>
  <property name="eclipse.weaving" value="false"/>
</properties>

我仍然不知道会发生什么,但我发现了问题:我有两个持久性.xml una 在我的耳朵应用程序中打包的库中,另一个在 ejb 模块中。所以我删除了 de ejb 模块上的那个,并将其持久性单元放在库的同一文件中。并且工作正常。我仍然不知道为什么它在自由服务器上工作正常,而在 IBM WAS 8.5 上失败。谢谢大家的帮助。

相关内容

  • 没有找到相关文章

最新更新