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.