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.  [ 1 post ] 
Author Message
 Post subject: can't get cascade in association mapping
PostPosted: Tue Feb 15, 2005 12:33 am 
Newbie

Joined: Tue Feb 15, 2005 12:18 am
Posts: 2
Comment:
I can't seem to get a cascading going when I add a transient Bid object into
Item object.


Hibernate version: 2.1

Mapping documents:
Code:
<hibernate-mapping package="com.nyker.test.hibernate">
  <class name="Item" table="ITEMS">
    <id name="id" column="ITEM_ID" type="long">
      <generator class="increment"/>
    </id>
    <property name="name"/>
   <set name="bids" cascade="all">
      <key column="ITEM_ID"/>
      <one-to-many class="Bid"/>
   </set>
  </class>
</hibernate-mapping>

<hibernate-mapping package="com.nyker.test.hibernate">
  <class name="Bid" table="BIDS">
    <id name="id" column="BID_ID" type="long">
      <generator class="increment"/>
    </id>
    <property name="amount"/>
  </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
Code:
Item item = (Item)session.load(Item.class,new Long(1L));
Bid bid1 = new Bid(144.22);
item.getBids().add(bid1);



Full stack trace of any exception that occurs:
Initialize Hibernate ...
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
done.
Hibernate: select item0_.ITEM_ID as ITEM_ID0_, item0_.name as name0_ from ITEMS item0_ where item0_.ITEM_ID=?
Hibernate: select bids0_.ITEM_ID as ITEM_ID__, bids0_.BID_ID as BID_ID__, bids0_.BID_ID as BID_ID0_, bids0_.amount as amount0_ from BIDS bids0_ where bids0_.ITEM_ID=?
Hibernate: update BIDS set amount=? where BID_ID=?
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:127)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2441)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.nyker.test.hibernate.Driver.testOneToManyReinsert(Driver.java:105)
at com.nyker.test.hibernate.Driver.main(Driver.java:110)
Exception in thread "main"


Name and version of the database you are using:
MySQL 4.1


The generated SQL (show_sql=true):
Hibernate: select item0_.ITEM_ID as ITEM_ID0_, item0_.name as name0_ from ITEMS item0_ where item0_.ITEM_ID=?
Hibernate: select bids0_.ITEM_ID as ITEM_ID__, bids0_.BID_ID as BID_ID__, bids0_.BID_ID as BID_ID0_, bids0_.amount as amount0_ from BIDS bids0_ where bids0_.ITEM_ID=?
Hibernate: update BIDS set amount=? where BID_ID=?


Debug level Hibernate log excerpt:


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

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.