Joined: Wed Jul 20, 2005 3:42 am Posts: 3
|
Hi i'm having a problem updating an object inside a Map...
Parent Table
PARENT_ID <--Primary Key
ParentName varchar(20)
OneToMany Table
ID <-- Primary Key
AttributeA varchar(20)
AttributeB varchar(20)
PARENT_ID <--Foreign Key
The mapping for the Parent.java is as follows
.
.
.
<map name="oneToMany" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="PARENT_ID" />
<index column="ID" type="java.lang.Integer"/>
<one-to-many class="OneToMany"/>
</map>
For the OneToMany.java
<many-to-one name="personalInfo" column="PERSONALINFO_ID" not-null="true"/>
There is no problem inserting to the Parent table and even inserting data int the OneToMany Table...
The problem is how do I update.
Example my collection of one to may may have 5 objects.
how do I update object 3?
I tried doing this...
this.oneToMany = (OneToMany)parent.getOneToMany().get(new Integer(pi.getId()) );
then update the values of the oneToMany... however, I realized that the parent table Id that i used to find the Map object is only applicable for one-to-one or a Set with only one object inside.
Need help please...
Hibernate version: 3
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: MySQL 4.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|
|