数据输入由Hibernate Constraint Violation异常停止

时间:2014-08-28 19:08:50

标签: oracle hibernate java-ee websphere

我有一个在jsf 1.2中开发的应用程序,富有面孔3. Oracle 11gR2正在持有架构。部署在Websphere 7.应用程序集中部署,多个用户通过WAN访问它。问题是......突然间数据输入停止了...... Websphere日志给了我以下内容: - 当我在websphere上重启应用程序时,数据输入再次开始,然后再次任意停止。

00000096 SystemErr     R org.hibernate.exception.ConstraintViolationException: could not insert: [org.dao.EmployeeDetail]  
00000096 SystemErr     R     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)  
00000096 SystemErr     R     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)  
00000096 SystemErr     R     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2285)
00000096 SystemErr     R     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
00000096 SystemErr     R     at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
00000096 SystemErr     R     at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
00000096 SystemErr     R     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
00000096 SystemErr     R     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
00000096 SystemErr     R     at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
00000096 SystemErr     R     at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
00000096 SystemErr     R     at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
00000096 SystemErr     R     at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
00000096 SystemErr     R     at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
00000096 SystemErr     R     at org.dal.EmployeeDetailDal.insertRecord(EmployeeDetailDal.java:122)
00000096 SystemErr     R     at org.bll.EmployeeDetailBll.insertion(EmployeeDetailBll.java:24)
00000096 SystemErr     R     at org.ui.beans.EmployeeDetailBean.save(EmployeeDetailBean.java:384)
00000096 SystemErr     R     at sun.reflect.GeneratedMethodAccessor11791.invoke(Unknown Source)
00000096 SystemErr     R     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
00000096 SystemErr     R     at java.lang.reflect.Method.invoke(Method.java:600)
00000096 SystemErr     R     at org.apache.el.parser.AstValue.invoke(AstValue.java:159)
00000096 SystemErr     R     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
00000096 SystemErr     R     at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:67)
00000096 SystemErr     R     at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
00000096 SystemErr     R     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
00000096 SystemErr     R     at javax.faces.component.UICommand.broadcast(UICommand.java:387)
00000096 SystemErr     R     at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
00000096 SystemErr     R     at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
00000096 SystemErr     R     at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
00000096 SystemErr     R     at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
00000096 SystemErr     R     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
00000096 SystemErr     R     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
00000096 SystemErr     R     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
00000096 SystemErr     R     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
00000096 SystemErr     R     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
00000096 SystemErr     R     at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
00000096 SystemErr     R     at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
00000096 SystemErr     R     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
00000096 SystemErr     R     at restricted.AuthorizationFilter.doFilter(AuthorizationFilter.java:188)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:934)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
00000096 SystemErr     R     at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
00000096 SystemErr     R     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:445)
00000096 SystemErr     R     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:504)
00000096 SystemErr     R     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)
00000096 SystemErr     R     at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
00000096 SystemErr     R     at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
00000096 SystemErr     R     at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
00000096 SystemErr     R     at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
00000096 SystemErr     R     at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
00000096 SystemErr     R     at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
00000096 SystemErr     R     at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
00000096 SystemErr     R     at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
00000096 SystemErr     R     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1563)
00000096 SystemErr     R Caused by: com.ibm.websphere.ce.cm.DuplicateKeyException:  ORA-00001: unique constraint (EMP_SCHEMA.EMPLOYEE_DETAIL_PK) violated
00000096 SystemErr     R 
00000096 SystemErr     R     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
00000096 SystemErr     R     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
00000096 SystemErr     R     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
00000096 SystemErr     R     at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
00000096 SystemErr     R     at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper(GenericDataStoreHelper.java:605)
00000096 SystemErr     R     at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:667)
00000096 SystemErr     R     at com.ibm.ws.rsadapter.AdapterUtil.mapException(AdapterUtil.java:2111)
00000096 SystemErr     R     at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:1034)
00000096 SystemErr     R     at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:826)
00000096 SystemErr     R     at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
00000096 SystemErr     R     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2265)
00000096 SystemErr     R     ... 64 more

   ….

EmployeeDetail的hbm文件在

下面
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.dao.EmployeeDetail" table="EMPLOYEE_DETAIL">
<id name="id" type="long" column="EMPLOYEE_ID">
<generator class="increment"></generator>
</id>
....    
</class>
</hibernate-mapping>

插入功能如下: -

…
EmployeeDetail empDet = new EmployeeDetail();
session = sessionFactory.openSession((Interceptor)localInterceptor.get());
session.setFlushMode(FlushMode.COMMIT);
Transaction transaction = session.beginTransaction();

    try {


            empDet.setEmpName (empDetBean.getEmpName());
                                               ….
            session.save(empDet);
            transaction.commit();
            session.flush();


    } catch (Exception e) {

        transaction.rollback();
        e.printStackTrace();

    } finally {
        session.close();
    }

请建议我采取措施。到目前为止,我已经在Websphere中尝试了不同的设置,如会话管理和数据源连接。同样,在代码中对hibernate会话应用了严格的检查。关闭会话,我明确打开它们但没有成功。

提前致谢。

0 个答案:

没有答案