-->
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: Foreignkey feild problem
PostPosted: Thu Feb 04, 2010 11:44 am 
Newbie

Joined: Thu Feb 04, 2010 11:12 am
Posts: 2
Hi all,

I'm new to hibernate. I started working on a Spring + hibernate project recently. Since I'm new to hibernate, i reversed engineered the DAOs from the database and went through them. I have 2 tables named user_roles and users in my database and the user_role_id column of users table references id column of user_roles table. (Foreign key constraint).

In the Users.java class i had all the setter methods to create a user object but no setters for user_role_id, instead of that there was a setter method for UserRoles object. So i thought to create a UserRoles object and set it so it will lookup and automatically assigns the id, but when creating the UserRoles object i found that it requires Set<Users> collection to be set since of the many to one relation. Nw I'm really confused how to insert a user record since there is a cyclic dependency in the classes. (I dont know whether this is the correct way, but since these are generated classes i thought this is the standard way to follow.)

Can anybody guide me how to insert a user record with user_role_id????

Thanks in advance.


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.