-->
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: Retrieval Problem In Primary Key Table
PostPosted: Sat Sep 29, 2007 1:18 am 
Newbie

Joined: Sat Sep 29, 2007 12:54 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1
Mapping documents:

For UserTypes Table:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

<class name="com.useradmin.beans.admin.UserTypes" table="usertypes" lazy="true">
<id name="id" column="typeid" unsaved-value="0">
<generator class="increment" />
</id>
<property name="typeName" column="typeName" not-null="true" length="50"/>

<set name="users" cascade="all" inverse="false" >
<key column="userid"/>
<one-to-many class="com.useradmin.beans.admin.User"/>
</set>

</class>
</hibernate-mapping>

For User Table:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.useradmin.beans.admin.User" table="users" >
<id name="id" column="userid" unsaved-value="0">
<generator class="increment" />
</id>

<many-to-one name="usertypes" column="typeid" update="false" class="com.useradmin.beans.admin.UserTypes"
not-null="true" lazy="no-proxy" >
</many-to-one>

<property name="firstname" column="firstname" not-null="false" length="50"/>
<property name="lastName" column="lastname" not-null="false" length="16"></property>
<property name="address" column="address" not-null="false" length="16"/>
<property name="email" column="email" not-null="false"/>
<property name="login" column="login" not-null="false" length="50"></property>
<property name="password" column="password" not-null="false" length="50"/>


</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

List<UserTypes> list = session.createQuery("from UserTypes").list();
This is returning the records from User class as well.

Full stack trace of any exception that occurs:

There is not any exception.
Problem is after mapping both of these classes when i execute the HQL
"from UserTypes" its returning the data from user class as well.
I am getting both tables records from this query..

Name and version of the database you are using:
MSSQL SERVER

The generated SQL (show_sql=true):
Hibernate: select usertypes0_.typeid as typeid1_, usertypes0_.typeName as typeName1_ from usertypes usertypes0_
Hibernate: select user0_.userid as userid3_, user0_.typeid as typeid3_, user0_.firstname as firstname3_, user0_.lastname as lastname3_, user0_.address as address3_, user0_.email as email3_, user0_.login as login3_, user0_.password as password3_ from users user0_


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.