Using Query (Object) ocurr violates foreign key in transaction
--------------------------------------------------------------
Key: HHH-3617
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3617
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: "PostgreSQL 8.2.5 on i686-pc-linux-gnu, compiled by GCC gcc
(GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)"
Hibernate core 3.3.1 and the only required library
Reporter: Clayton K. N. Passos
Attachments: Car.hbm.xml, MainTest.java, Travel.hbm.xml
Using Query (Object) ocurr violates foreign key in transaction
Look MainTest and Query object:
Query query = session.createQuery(sb.toString());
int row = query.executeUpdate();
I expect that the behavior be the even though Session.delete(...), but it´s not true.
The exception occurs below:
Exception in thread "main" org.hibernate.exception.ConstraintViolationException:
could not execute update query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:107)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:419)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1168)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
at com.MainTest.main(MainTest.java:54)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table
"car" violates foreign key constraint "fk95cb6b3a78a8fea5" on table
"travel"
Detalhe: Key (idcar)=(1) is still referenced from table "travel".
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:305)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:98)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira