-->
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: Composite ids & rows not created in database.
PostPosted: Fri Sep 12, 2003 2:47 am 
Newbie

Joined: Wed Sep 03, 2003 9:08 am
Posts: 18
I have a class with composite id mapped to a table. Here's the hibernate mapping of the file.

Code:

    <class name="UserParams" table="USERPARAMS" dynamic-update="true">

        <composite-id>
            <key-property name="memberID" column="MEMBERID" type="integer" />
            <key-property name="paramID" column="PARAMID" type="integer" />
        </composite-id>

        <property name="value" column="VALUE" type="string" />
    </class>




I'm creating adding new rows to the database in a for loop. However, when I commit the transaction, the rows are not added to the database. No errors are printed in the console. I have also implemented equals() and hashcode() methods(since this class is participating in a one-to-many relation with user).

The mapping for the userparams part in the user is:

Code:
        <set name="params" lazy="true" cascade="all" inverse="true" >
            <key column="memberID" />
            <one-to-many class="UserParams" />
        </set>


Please note that I'm not adding the rows by adding it to the "User" class(Actually I've tried to add by setting the parameters in user also. It doesn't work either). Instead by separately adding it to the database something like:

Code:

session.save(user); //for saving the user details to db

for(<list of params>)
{
     session.save(new UserParams(...));
}



When I run hibernate in debug mode, it is printing saying batch update is done for 9 rows(no. of parameters i'm trying to insert). But the entries are not added to the database.

Also, the user details are correctly added to the database.

Can anybody please explain me what is the problem with the above mappings and code?

I'm using Oracle 9 with Hibernate 2.1r2.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 4:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Make sure you commit the transaction.


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.