-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Issues using <list> collection mapping. Unable to dele
PostPosted: Fri Sep 15, 2006 11:19 am 
Newbie

Joined: Fri Sep 15, 2006 11:00 am
Posts: 1
Issue Description:

I am able to persist a PersistentQueue obj that contains a list of PersistentMessages. I am unable to remove a Message from the PersistentQueue obj and call .saveOrUpdate(PersistentQueue obj).
View relevant details below.

Also are there better examples of using bi-derectional indexed collection which include the mapping file (And possibly the table structure)?
I have the Hibernate in Action book as well as the .pdf reference but the mapping that works for me is diffferent and the variety of examples are low in those docs.


Hibernate version: 3.0.5

JDK version: 1.4.2

Sql to create DB tables:
Code:
CREATE TABLE queues
(
   queue_id               SERIAL         NOT NULL,
   version                  INTEGER,
   name                  VARCHAR(30)      UNIQUE NOT NULL,
   CONSTRAINT pk_queues_queue_id             PRIMARY KEY (queue_id)
) WITHOUT OIDS;

CREATE TABLE messages
(
   message_id               SERIAL         NOT NULL,
   version                  INTEGER,
   position_ind            INTEGER         NOT NULL,
   message_type            VARCHAR(3)      NOT NULL,
   parent_queue_id            INTEGER         NOT NULL,
   CONSTRAINT pk_messages_message_id          PRIMARY KEY (message_id),
   CONSTRAINT check_position_queue            UNIQUE(position_ind, parent_queue_id),
   CONSTRAINT fk_parent_queue_id            FOREIGN KEY (parent_queue_id)      REFERENCES queues(queue_id)
) WITHOUT OIDS;


Mapping documents:

Code:
<class name="PersistentQueue"  table="queues">
      <id column="queue_id" name="queueId" type="long">
         <generator class="sequence">
            <param name="sequence">queues_queue_id_seq</param>
           </generator>
      </id>      
      
      <version  column="version"      name="version"           unsaved-value="negative" />
      
      <property column="name"      name="name"        length="30"     not-null="true" unique="true"   type="string"/>
      
      <list name="messages" inverse="false" cascade="all-delete-orphan" >
         <key >
            <column name="parent_queue_id" not-null="true" />
         </key>
         <list-index column="position_ind" base="0" />
         <one-to-many class="PersistentMessage"  />
      </list>
      
   </class>

<class name="PersistentMessage"  table="messages" >
      
      <id column="message_id" name="messageId" type="long">
         <generator class="sequence">
            <param name="sequence">queues_queue_id_seq</param>
           </generator>
      </id>      
      
      <version  column="version"      name="version"           unsaved-value="negative" />

      <property column="message_type"      name="messageType"   length="3" not-null="true" type="string"/>
      
      <many-to-one column="parent_queue_id" name="parentQueue" class="PersistentQueue"
                 />      
   </class>




Full stack trace of any exception that occurs:
Code:
com.mchange.v2.c3p0.impl.NewPooledConnection@1fe88d invalidated by Exception: Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:107)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:138)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)14:59:12,651  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
WARN [main] (JDBCExceptionReporter.java:71) - SQL Error: 0, SQLState: null
14:59:12,651 ERROR JDBCExceptionReporter:72 - Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
ERROR [main] (JDBCExceptionReporter.java:72) - Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
14:59:12,651  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 23502
WARN [main] (JDBCExceptionReporter.java:71) - SQL Error: 0, SQLState: 23502
14:59:12,651 ERROR JDBCExceptionReporter:72 - ERROR: null value in column "parent_queue_id" violates not-null constraint

ERROR [main] (JDBCExceptionReporter.java:72) - ERROR: null value in column "parent_queue_id" violates not-null constraint

14:59:12,651 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63)
   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:138)
   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 za.co.kts.forexPayments.persistance.ForexPaymentsDAO.getPersistentQueueForName(ForexPaymentsDAO.java:1127)
   at za.co.kts.forexPayments.test.TestHibernateUtil.deleteMessage(TestHibernateUtil.java:120)
   at za.co.kts.forexPayments.test.TestHibernateUtil.main(TestHibernateUtil.java:40)
Caused by: Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:107)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   ... 11 more
ERROR [main] (AbstractFlushingEventListener.java:277) - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63)
   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:138)
   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 za.co.kts.forexPayments.persistance.ForexPaymentsDAO.getPersistentQueueForName(ForexPaymentsDAO.java:1127)
   at za.co.kts.forexPayments.test.TestHibernateUtil.deleteMessage(TestHibernateUtil.java:120)
   at za.co.kts.forexPayments.test.TestHibernateUtil.main(TestHibernateUtil.java:40)
Caused by: Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:107)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   ... 11 more

   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 za.co.kts.forexPayments.persistance.ForexPaymentsDAO.getPersistentQueueForName(ForexPaymentsDAO.java:1127)
   at za.co.kts.forexPayments.test.TestHibernateUtil.deleteMessage(TestHibernateUtil.java:120)
   at za.co.kts.forexPayments.test.TestHibernateUtil.main(TestHibernateUtil.java:40)
CONNECTION ERROR OCCURRED!

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63)
   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:138)
   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 za.co.kts.forexPayments.persistance.ForexPaymentsDAO.getPersistentQueueForName(ForexPaymentsDAO.java:1127)
   at za.co.kts.forexPayments.test.TestHibernateUtil.deleteMessage(TestHibernateUtil.java:120)
   at za.co.kts.forexPayments.test.TestHibernateUtil.main(TestHibernateUtil.java:40)
Caused by: Batch entry 0 update public.messages set parent_queue_id=null, position_ind=null where parent_queue_id= was aborted. Call getNextException() to see the cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:107)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1722)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   ... 11 more



Name and version of the database you are using:
PostgreSQL, version: 7.4.1

_________________
Thanks
<Ajit Bawa>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 12:21 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 10:20 am
Posts: 32
Location: Brazil
Maybe it's related to this problem?

_________________
Don't forget to rate!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.