-->
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: unable to identify relationships
PostPosted: Wed Dec 17, 2008 4:11 am 
Newbie

Joined: Thu Nov 06, 2008 8:11 am
Posts: 3
Location: hyderabad
hi,

i am just started learning hibernate. i am developing a project which is simple forum.

So, i created my tables as
create table Topic(topic_id number(8) primary key, Topic_Name varchar2(41));

create table Questions(topic_id number(8),Question_id number(8), Questions varchar2(500), username varchar2(50), Q_Date Date)

alter table Questions add constraint fk TopicId references Topic(topic_id);


i got stuck up at one place i,e. which relationship mapping i have to use for inserting topic_id in both topic and questions table at a time.

i am planning to use generator class as "increment".
and based on topic_id i should generate question_id.. lets topic_id =1;topic_name="Java" question_id should start based on topic_id...


if you feel i am doing some thing wrong please suggest me a good approach

_________________
If the blind lead the blind, both shall fall in a ditch


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 6:22 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
Use sequence class as like that

<id column="USER_ID" name="id" type="java.lang.Long">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">idgen</param>
<param name="column">NEXT</param>
</generator>
</id>

idgen -- secondary table
NEXT -- foreign key

_________________
If u feel it will help you, don't forget to rate me....


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.