-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Mapping problem
PostPosted: Thu May 17, 2007 12:10 pm 
Newbie

Joined: Thu May 17, 2007 11:27 am
Posts: 8
Location: US
I am new to Hibernate. I try to do a one to many mapping for two table.
I setup the class file, and the hbm mapping xml file for two class. However, when I run the program. It can load the data from parent table. but it just return nothing for child.
my table is like following
create table INFO(
INFO_ID char(15),
APPLICAT varchar(255),
primary key (ID)
)

create table NO_BDATA_T(
INFO_ID char(15),
SEQ numeric(2),
BDATA text,
BDATA_DATE smalldatetime,
primary key(INFO_ID, SEQ)
)

on the Info xml
<set name="bdata" lazy="true" >
<key>
<column name="INFO_ID"/>
</key>
<one-to-many class="com.minicircuits.no.NO_BDATA" />
</set>

Everything is fine, no error message. Please help. I am so frustrated by it. I am trying so many way

_________________
Raemond


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 2:21 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Code:
lazy="true"


won't load any children if you load the parent. You'll get a proxy. You have to explicitly load the children inside the session with something like




Code:
Hibernate.initialize(parent.getChildren());


if that doesn't work, check the logs and find the sql statements issued or if any child objects are created

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 7:34 pm 
Newbie

Joined: Thu May 17, 2007 11:27 am
Posts: 8
Location: US
It doesn't work. I found out that if the table doesn't create the foreign key, the hibernate association won't work

_________________
Raemond


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.