-->
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: Is it bug or feature?
PostPosted: Fri Mar 19, 2004 11:39 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
I'm using hibernate 2.1.2 , and discovered that this mapping causes
problem while flushing.

Course.hbm.xml:
Code:
   <bag name="groups" lazy="true" cascade="delete">
      <key/>
      <one-to-many class="com.infodesire.educator.data.Group"/>
    </bag>


Group.hbm.xml:
Code:
<many-to-one name="course" not-null="true" cascade="none"/>


I create group following way:
Code:
          Group group = new Group();
            course.getGroups().add(group);
            group.setCourse(course);

            Session session = obtainSession();
            session.save(group);
            returnSession(session);


Then while flushing session, it tries to update collection
and botches primary key instead updating foreign key:
Code:
7745 [main] DEBUG net.sf.hibernate.SQL  - update course_group set id=? where id=?
Hibernate: update course_group set id=? where id=?
7746 [main] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
7748 [main] DEBUG net.sf.hibernate.type.IntegerType  - binding '1' to parameter: 1
7749 [main] DEBUG net.sf.hibernate.type.IntegerType  - binding '1' to parameter: 2
7749 [main] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
7760 [main] DEBUG net.sf.hibernate.type.IntegerType  - binding '1' to parameter: 1
7761 [main] DEBUG net.sf.hibernate.type.IntegerType  - binding '2' to parameter: 2
7761 [main] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch


When I specify column names explicitely on both sides, everything is fine.

And dtd says that column names for foreighn key are implied...
Is it minee fault or yours?

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 6:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
<key> column is not optional

_________________
Emmanuel


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.