-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Returning empty collection
PostPosted: Fri May 22, 2009 8:41 am 
Newbie

Joined: Fri May 22, 2009 8:26 am
Posts: 2
Hi,
I am new to Hibernate and is stuck up with a problem.

I have 2 tables University and Pincode.
I am trying to fetch the columns of the Pincode table for the University.
But it is coming as empty collection.
My mapping file--

<hibernate-mapping>

<class name="com.uessetupdataservices.beans.University" table="UNI_SET_UNIVERSITY_MAST">
<id name="id" column="UNIVERSITY_ID">
<generator class="assigned"/>
</id>
<property name="universityCode" column="UNIVERSITY_CODE"/>
<property name="universityName" column="UNIVERSITY_NAME"/>
<property name="universityShortName" column="UNIVERSITY_SHORT_NAME"/>
<property name="universityType" column="UNIVERSITY_TYPE"/>
<property name="dateOfEstablishment" column="DATE_OF_ESTABLISHMENT"/>
<property name="govtResolutionNo" column="GOVT_RESOLUTION_NO"/>
<property name="govtResolutionDate" column="GOVT_RESOLUTION_DATE"/>
<property name="accrediationLevel" column="ACCREDIATION_LEVEL"/>
<property name="accrediationAgency" column="ACCREDIATION_AGENCY"/>
<property name="history" column="HISTORY"/>
<property name="address1" column="ADDRESS1"/>
<property name="address2" column="ADDRESS2"/>
<property name="areaName" column="AREA_NAME"/>
<property name="pincode" column="PINCODE"/>
<property name="website" column="WEBSITE"/>
<property name="emailId" column="EMAIL_ID"/>
<property name="phone1" column="PHONE1"/>
<property name="phone2" column="PHONE2"/>
<property name="phone3" column="PHONE3"/>
<property name="phone4" column="PHONE4"/>
<property name="phone5" column="PHONE5"/>
<property name="phone6" column="PHONE6"/>
<property name="createdBy" column="CREATED_BY"/>
<property name="createdDate" column="CREATED_DATE"/>
<property name="modifiedBy" column="MODIFIED_BY"/>
<property name="modifiedDate" column="MODIFIED_DATE"/>
<property name="recordStatus" column="RECORD_STATUS"/>

<set name="pincodes" table="UNI_SET_PINCODE_MAST" lazy="false" >
<key column="PINCODE" />
<one-to-many class="com.uessetupdataservices.beans.Pincodes" />
</set>
</class>

<class name="com.uessetupdataservices.beans.Pincodes" table="UNI_SET_PINCODE_MAST" >
<id name="id" column="PINCODE">
<generator class="assigned"/>
</id>
<property name="cityId" column="CITY_ID"/>
<property name="districtId" column="DISTRICT_ID"/>
<property name="stateId" column="STATE_ID"/>
<property name="countryId" column="COUNTRY_ID"/>
<property name="createdBy" column="CREATED_BY"/>
<property name="createdDate" column="CREATED_DATE"/>
<property name="modifiedBy" column="MODIFIED_BY"/>
<property name="modifiedDate" column="MODIFIED_DATE"/>
<property name="recordStatus" column="RECORD_STATUS"/>

</class>
</hibernate-mapping>

The stacktrace --

4579 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
4610 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: from com.uessetupdataservices.beans.University university
4610 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select university0_.UNIVERSITY_ID as UNIVERSITY1_0_, university0_.UNIVERSITY_CODE as UNIVERSITY2_0_, university0_.UNIVERSITY_NAME as UNIVERSITY3_0_, university0_.UNIVERSITY_SHORT_NAME as UNIVERSITY4_0_, university0_.UNIVERSITY_TYPE as UNIVERSITY5_0_, university0_.DATE_OF_ESTABLISHMENT as DATE6_0_, university0_.GOVT_RESOLUTION_NO as GOVT7_0_, university0_.GOVT_RESOLUTION_DATE as GOVT8_0_, university0_.ACCREDIATION_LEVEL as ACCREDIA9_0_, university0_.ACCREDIATION_AGENCY as ACCREDI10_0_, university0_.HISTORY as HISTORY0_, university0_.ADDRESS1 as ADDRESS12_0_, university0_.ADDRESS2 as ADDRESS13_0_, university0_.AREA_NAME as AREA14_0_, university0_.PINCODE as PINCODE0_, university0_.WEBSITE as WEBSITE0_, university0_.EMAIL_ID as EMAIL17_0_, university0_.PHONE1 as PHONE18_0_, university0_.PHONE2 as PHONE19_0_, university0_.PHONE3 as PHONE20_0_, university0_.PHONE4 as PHONE21_0_, university0_.PHONE5 as PHONE22_0_, university0_.PHONE6 as PHONE23_0_, university0_.CREATED_BY as CREATED24_0_, university0_.CREATED_DATE as CREATED25_0_, university0_.MODIFIED_BY as MODIFIED26_0_, university0_.MODIFIED_DATE as MODIFIED27_0_, university0_.RECORD_STATUS as RECORD28_0_ from UNI_SET_UNIVERSITY_MAST university0_
4610 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
4688 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
4688 [main] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
4766 [main] DEBUG org.hibernate.SQL - select university0_.UNIVERSITY_ID as UNIVERSITY1_0_, university0_.UNIVERSITY_CODE as UNIVERSITY2_0_, university0_.UNIVERSITY_NAME as UNIVERSITY3_0_, university0_.UNIVERSITY_SHORT_NAME as UNIVERSITY4_0_, university0_.UNIVERSITY_TYPE as UNIVERSITY5_0_, university0_.DATE_OF_ESTABLISHMENT as DATE6_0_, university0_.GOVT_RESOLUTION_NO as GOVT7_0_, university0_.GOVT_RESOLUTION_DATE as GOVT8_0_, university0_.ACCREDIATION_LEVEL as ACCREDIA9_0_, university0_.ACCREDIATION_AGENCY as ACCREDI10_0_, university0_.HISTORY as HISTORY0_, university0_.ADDRESS1 as ADDRESS12_0_, university0_.ADDRESS2 as ADDRESS13_0_, university0_.AREA_NAME as AREA14_0_, university0_.PINCODE as PINCODE0_, university0_.WEBSITE as WEBSITE0_, university0_.EMAIL_ID as EMAIL17_0_, university0_.PHONE1 as PHONE18_0_, university0_.PHONE2 as PHONE19_0_, university0_.PHONE3 as PHONE20_0_, university0_.PHONE4 as PHONE21_0_, university0_.PHONE5 as PHONE22_0_, university0_.PHONE6 as PHONE23_0_, university0_.CREATED_BY as CREATED24_0_, university0_.CREATED_DATE as CREATED25_0_, university0_.MODIFIED_BY as MODIFIED26_0_, university0_.MODIFIED_DATE as MODIFIED27_0_, university0_.RECORD_STATUS as RECORD28_0_ from UNI_SET_UNIVERSITY_MAST university0_
Hibernate: select university0_.UNIVERSITY_ID as UNIVERSITY1_0_, university0_.UNIVERSITY_CODE as UNIVERSITY2_0_, university0_.UNIVERSITY_NAME as UNIVERSITY3_0_, university0_.UNIVERSITY_SHORT_NAME as UNIVERSITY4_0_, university0_.UNIVERSITY_TYPE as UNIVERSITY5_0_, university0_.DATE_OF_ESTABLISHMENT as DATE6_0_, university0_.GOVT_RESOLUTION_NO as GOVT7_0_, university0_.GOVT_RESOLUTION_DATE as GOVT8_0_, university0_.ACCREDIATION_LEVEL as ACCREDIA9_0_, university0_.ACCREDIATION_AGENCY as ACCREDI10_0_, university0_.HISTORY as HISTORY0_, university0_.ADDRESS1 as ADDRESS12_0_, university0_.ADDRESS2 as ADDRESS13_0_, university0_.AREA_NAME as AREA14_0_, university0_.PINCODE as PINCODE0_, university0_.WEBSITE as WEBSITE0_, university0_.EMAIL_ID as EMAIL17_0_, university0_.PHONE1 as PHONE18_0_, university0_.PHONE2 as PHONE19_0_, university0_.PHONE3 as PHONE20_0_, university0_.PHONE4 as PHONE21_0_, university0_.PHONE5 as PHONE22_0_, university0_.PHONE6 as PHONE23_0_, university0_.CREATED_BY as CREATED24_0_, university0_.CREATED_DATE as CREATED25_0_, university0_.MODIFIED_BY as MODIFIED26_0_, university0_.MODIFIED_DATE as MODIFIED27_0_, university0_.RECORD_STATUS as RECORD28_0_ from UNI_SET_UNIVERSITY_MAST university0_
4907 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
4938 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.uessetupdataservices.beans.University#1]
4954 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.uessetupdataservices.beans.University#2]
4954 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
4954 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
4969 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.uessetupdataservices.beans.University#1]
4985 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [com.uessetupdataservices.beans.University#1]
4985 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [com.uessetupdataservices.beans.University#2]
4985 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [com.uessetupdataservices.beans.University#2]
4985 [main] DEBUG org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy collections
5000 [main] DEBUG org.hibernate.loader.Loader - loading collection: [com.uessetupdataservices.beans.University.pincodes#2]
5000 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
5000 [main] DEBUG org.hibernate.SQL - select pincodes0_.PINCODE as PINCODE1_, pincodes0_.PINCODE as PINCODE1_0_, pincodes0_.CITY_ID as CITY2_1_0_, pincodes0_.DISTRICT_ID as DISTRICT3_1_0_, pincodes0_.STATE_ID as STATE4_1_0_, pincodes0_.COUNTRY_ID as COUNTRY5_1_0_, pincodes0_.CREATED_BY as CREATED6_1_0_, pincodes0_.CREATED_DATE as CREATED7_1_0_, pincodes0_.MODIFIED_BY as MODIFIED8_1_0_, pincodes0_.MODIFIED_DATE as MODIFIED9_1_0_, pincodes0_.RECORD_STATUS as RECORD10_1_0_ from UNI_SET_PINCODE_MAST pincodes0_ where pincodes0_.PINCODE=?
Hibernate: select pincodes0_.PINCODE as PINCODE1_, pincodes0_.PINCODE as PINCODE1_0_, pincodes0_.CITY_ID as CITY2_1_0_, pincodes0_.DISTRICT_ID as DISTRICT3_1_0_, pincodes0_.STATE_ID as STATE4_1_0_, pincodes0_.COUNTRY_ID as COUNTRY5_1_0_, pincodes0_.CREATED_BY as CREATED6_1_0_, pincodes0_.CREATED_DATE as CREATED7_1_0_, pincodes0_.MODIFIED_BY as MODIFIED8_1_0_, pincodes0_.MODIFIED_DATE as MODIFIED9_1_0_, pincodes0_.RECORD_STATUS as RECORD10_1_0_ from UNI_SET_PINCODE_MAST pincodes0_ where pincodes0_.PINCODE=?
5016 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
5016 [main] DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [com.uessetupdataservices.beans.University.pincodes#2]
5016 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
5016 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
5016 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections were found in result set for role: com.uessetupdataservices.beans.University.pincodes
5016 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - collection fully initialized: [com.uessetupdataservices.beans.University.pincodes#2]
5016 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections initialized for role: com.uessetupdataservices.beans.University.pincodes
5016 [main] DEBUG org.hibernate.loader.Loader - done loading collection
5016 [main] DEBUG org.hibernate.loader.Loader - loading collection: [com.uessetupdataservices.beans.University.pincodes#1]
5016 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
5016 [main] DEBUG org.hibernate.SQL - select pincodes0_.PINCODE as PINCODE1_, pincodes0_.PINCODE as PINCODE1_0_, pincodes0_.CITY_ID as CITY2_1_0_, pincodes0_.DISTRICT_ID as DISTRICT3_1_0_, pincodes0_.STATE_ID as STATE4_1_0_, pincodes0_.COUNTRY_ID as COUNTRY5_1_0_, pincodes0_.CREATED_BY as CREATED6_1_0_, pincodes0_.CREATED_DATE as CREATED7_1_0_, pincodes0_.MODIFIED_BY as MODIFIED8_1_0_, pincodes0_.MODIFIED_DATE as MODIFIED9_1_0_, pincodes0_.RECORD_STATUS as RECORD10_1_0_ from UNI_SET_PINCODE_MAST pincodes0_ where pincodes0_.PINCODE=?
Hibernate: select pincodes0_.PINCODE as PINCODE1_, pincodes0_.PINCODE as PINCODE1_0_, pincodes0_.CITY_ID as CITY2_1_0_, pincodes0_.DISTRICT_ID as DISTRICT3_1_0_, pincodes0_.STATE_ID as STATE4_1_0_, pincodes0_.COUNTRY_ID as COUNTRY5_1_0_, pincodes0_.CREATED_BY as CREATED6_1_0_, pincodes0_.CREATED_DATE as CREATED7_1_0_, pincodes0_.MODIFIED_BY as MODIFIED8_1_0_, pincodes0_.MODIFIED_DATE as MODIFIED9_1_0_, pincodes0_.RECORD_STATUS as RECORD10_1_0_ from UNI_SET_PINCODE_MAST pincodes0_ where pincodes0_.PINCODE=?
5047 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
5047 [main] DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [com.uessetupdataservices.beans.University.pincodes#1]
5047 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
5047 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
5047 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections were found in result set for role: com.uessetupdataservices.beans.University.pincodes
5047 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - collection fully initialized: [com.uessetupdataservices.beans.University.pincodes#1]
5047 [main] DEBUG org.hibernate.engine.loading.CollectionLoadContext - 1 collections initialized for role: com.uessetupdataservices.beans.University.pincodes
5047 [main] DEBUG org.hibernate.loader.Loader - done loading collection
5047 [main] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
5047 [main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate - Eagerly flushing Hibernate session
5047 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
5047 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
5063 [main] DEBUG org.hibernate.engine.Collections - Collection found: [com.uessetupdataservices.beans.University.pincodes#1], was: [com.uessetupdataservices.beans.University.pincodes#1] (initialized)
5063 [main] DEBUG org.hibernate.engine.Collections - Collection found: [com.uessetupdataservices.beans.University.pincodes#2], was: [com.uessetupdataservices.beans.University.pincodes#2] (initialized)
5063 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
5063 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 2 collections
5063 [main] DEBUG org.hibernate.pretty.Printer - listing entities:

Can you please help me

Thanks
Swapan


Top
 Profile  
 
 Post subject: Re: Hibernate Returning empty collection
PostPosted: Fri May 22, 2009 4:14 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
You using PINCODE as key column in your set which is the primary key for your pincode class.

You can try tsomething like this:
Code:
<class name="com.uessetupdataservices.beans.University" table="UNI_SET_UNIVERSITY_MAST">
< id name="id" column="UNIVERSITY_ID">
<generator class="assigned"/>
</id>
....
<set name="pincodes" table="UNI_SET_PINCODE_MAST" lazy="false" >
  <key column="UNIVERSITY_FK" />
   <one-to-many class="com.uessetupdataservices.beans.Pincodes" />
  </set>
</class>


Christophe


Top
 Profile  
 
 Post subject: Re: Hibernate Returning empty collection
PostPosted: Sat May 23, 2009 2:22 am 
Newbie

Joined: Fri May 22, 2009 8:26 am
Posts: 2
It worked...Thanx a bunch...


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