Hi,
I have a strange ConstraintViolationException with a criteria.uniqueResult().
I have EJB Session witch used Hibernate for the persitence. (see configuration files for more information)
When I launch one instance of my EJB, it works perfectly but when i launch severals instances, I can have a ConstraintViolationException.
Thanks for your help.
Hibernate version: 3.05
Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = HibernateUtil.getSession().createCriteria(Workflow.class);
criteria.setMaxResults(1);
criteria.add(Restrictions.eq("process", process));
criteria.createCriteria("actor").createCriteria("actorRef")
.add(Restrictions.eq("codingScheme", actorRef.getCodingScheme()))
.add(Restrictions.eq("identification", actorRef.getIdentification()))
.add(Restrictions.eq("role", actorRef.getRole()));
criteria.createCriteria("applicationInterval")
.add(Restrictions.eq("begin", applicationBegin))
.add(Restrictions.eq("end", applicationEnd));
criteria.add(Restrictions.isNull("openInterval"));
criteria.add(Restrictions.isNull("aperture"));
return (Workflow)criteria.uniqueResult();
Full stack trace of any exception that occurs:Quote:
11:10:49,203 DEBUG HibernateUtil: Committing database transaction of this thread.
11:10:49,218 WARN JDBCExceptionReporter: SQL Error: 2291, SQLState: 23000
11:10:49,218 ERROR JDBCExceptionReporter: ORA-02291: violation de contrainte (ETSO_TEST.FK25B334C4E5432E06) d'intégrité - touche parent introuvable
11:10:49,218 WARN JDBCExceptionReporter: SQL Error: 2291, SQLState: 23000
11:10:49,218 ERROR JDBCExceptionReporter: ORA-02291: violation de contrainte (ETSO_TEST.FK25B334C4E5432E06) d'intégrité - touche parent introuvable
11:10:49,218 ERROR AbstractFlushingEventListener: Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:48)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:711)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1315)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:433)
at com.rte.etso.validation.dao.hibernate.WorkflowDaoHibernate.retrieveWorkflowByProcessActorAndIntervals(WorkflowDaoHibernate.java:89)
at com.rte.etso.validation.service.workflow.impl.ProgrammationWorkflowService.retrieveCorrectWorkflow(ProgrammationWorkflowService.java:81)
at com.rte.etso.validation.service.workflow.impl.ProgrammationWorkflowService.retrieveWorkflow(ProgrammationWorkflowService.java:158)
at com.rte.etso.validation.service.workflow.impl.ProgrammationWorkflowService.retrieveWorkflowOrCreate(ProgrammationWorkflowService.java:129)
at com.rte.etso.validation.facade.generation.XMLFileGenerationServicesBean.initializeWorkflow(XMLFileGenerationServicesBean.java:74)
at com.rte.etso.validation.facade.generation.XMLFileGenerationServicesBean.createAndSaveValidatedXMLFile(XMLFileGenerationServicesBean.java:253)
at com.rte.etso.validation.facade.generation.XMLFileGenerationServices_dlf63u_EOImpl.createAndSaveValidatedXMLFile(XMLFileGenerationServices_dlf63u_EOImpl.java:46)
at com.rte.etso.validation.facade.generation.XMLFileGenerationServices_dlf63u_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.sql.BatchUpdateException: ORA-02291: violation de contrainte (ETSO_TEST.FK25B334C4E5432E06) d'intégrité - touche parent introuvable
Name and version of the database you are using: Oracle 9.02i.
Hibernate Configuration FilesCode:
<hibernate-configuration>
<session-factory>
<!-- Enable CGLIB reflection optimizer (enabled by default) -->
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<!-- properties -->
<property name="connection.datasource">jdbc/etso</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.connection.autocommit">false</property>
<!-- Use ClassicQuery to not use antlr -->
<property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>
<!-- Transaction integration -->
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WeblogicTransactionManagerLookup
</property>
<!-- Mapping files -->
[...]
</session-factory>
</hibernate-configuration>