-->
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.  [ 5 posts ] 
Author Message
 Post subject: Composite key proble, please give hint
PostPosted: Sun Jan 30, 2005 5:08 am 
Newbie

Joined: Sat Dec 25, 2004 11:03 am
Posts: 8
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.1

Mapping documents: 3

<hibernate-mapping package="mapping">
<class name="Role" table="ROLE">
<id name="roleid" column="ROLEID" type="java.lang.Long">
<generator class="hilo"/>
</id>
<property name="rolename" column="ROLENAME" />
</class>
</hibernate-mapping>
-------------------------------------------------------------------------
<hibernate-mapping package="mapping">

<class name="Users" table="USERS">
<id name="userid" column="USERID" type="java.lang.Long">
<generator class="hilo"/>
</id>
<many-to-one name="functionalgroup" column="GROUPID" class="Functionalgroup" not-null="true" />

<many-to-one name="location" column="LOCATIONID" class="Location" />
</class>
-------------------------------------------------------------------------------
<hibernate-mapping package="mapping">
<class name="UsersRoles" table="USERS_ROLES">
<composite-id name="id" class="UsersRolesKey">
<key-many-to-one name="role" column="ROLEID" class="Role"/>
<key-many-to-one name="users" column="USERID" class="Users"/>
</composite-id>

</class>

</hibernate-mapping>
-----------------------------------------------------------------------------------

These 3 are my mapping files, it basically representa login module
if users enters user/paswd i want to fetch all the roles associated with it.

Users aUser = (Users)session.find("from Users as r").get(0);
Roles role = aUser.getRoles();

but role always coming null, Why?
what is the correct way to get the roles.

Please give hint

regards
Puneet


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 7:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your code does not match your mapping documents.
Where is getRoles() [Roles property] in the mapping for users?


Top
 Profile  
 
 Post subject: do we have to make changes manually
PostPosted: Sun Jan 30, 2005 11:48 pm 
Newbie

Joined: Sat Dec 25, 2004 11:03 am
Posts: 8
But i have generated it through the DB Browser in the Eclipse.
does this mean we have to manually make the changes in the xml files.
what if i have hundred mapping file?

regards
Puneet


Top
 Profile  
 
 Post subject: It is working fine
PostPosted: Mon Jan 31, 2005 12:36 am 
Newbie

Joined: Sat Dec 25, 2004 11:03 am
Posts: 8
Hi,

One should read book by maning publication.
It clears the basics

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 8:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You have solved your problem - great.
BTW: Try Middlegen for hibernate 2.x database reverse engineering.


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