-->
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: Help, hibernate
PostPosted: Wed Mar 10, 2010 1:21 am 
Newbie

Joined: Wed Mar 10, 2010 1:02 am
Posts: 3
Hello . . i am newbie in hibernate

I have some question about save foreign key from 2 table that have related
first table :
#student table structure
id varchar(2)
name varchar(45)
course_id varchar(2)

#course table structure
course_id varchar(2)
course_name varchar(50)

And i generate entity class from two table above automatically using netbeans, So the type of courseId at the student class would be "course" type...and i create JFrame an some textfield to input the date to table. but i have problem when i would save courseId that the type is different from student table data type at course_id column.at the table the data type is varchar but at the entity class the type is Course.
Any body can help me
I'm so sorry for my bad english,cause i'm indonesian. :-)


Top
 Profile  
 
 Post subject: Re: Help, hibernate
PostPosted: Wed Mar 10, 2010 2:02 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Hi, just a suggestion to use many-to-many relationship, because student maybe can have many courses.

To solve your issue, you need to retrieve the Course by id
Code:
Course course = session.load(Course.class, courseId);


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.