-->
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: One-To-Many Updating Map (LinkedHashMap)
PostPosted: Wed Aug 03, 2005 10:59 pm 
Newbie

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:


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.