-->
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: Collections not being loaded
PostPosted: Thu Jun 12, 2008 3:01 pm 
Newbie

Joined: Thu Jun 12, 2008 1:14 am
Posts: 4
I have spent a bunch of hours hacking at this new task, and I am still
having issues. Everything a compiles fine, and I am able to retrieve the locations using the query "getLocations", but the data in
the collection tables is not being returned. No errors are generated.
I am logging the sql that is being used (using log4j) and it shows the
attempts to load the ReferralType collection for each location, but I guess it doesn't find anything.  I put a sample of my table data below the mapping, and below that some of the SQL logs:

Thank you so much for looking at this!!

<hibernate-mapping default-lazy="false">
   <class name="test.Location" table="location" >
       <id name="id" column="id" type="java.lang.Integer">
       </id>
       <property name="location" column="location" type="java.lang.String"/>
       <property name="street" column="street" type="java.lang.String"/>
       <property name="city" column="city" type="java.lang.String"/>
       <property name="state" column="state" type="java.lang.String"/>
       <property name="zip" column="zip" type="java.lang.String"/>
       <property name="hrContactEmail" column="hr_contact_email" type="java.lang.String"/>
       <property name="isVisible" column="is_visible" type="java.lang.Boolean"/>
       <list name="referralType" table="referral_type">
           <key column="state" />
           <list-index column="list_index" />
           <one-to-many class="test.ReferralType" />
       </list>
   </class>
   <class name="test.ReferralType" table="referral_type">
       <id name="id" column="id" type="java.lang.Integer">
       </id>
       <property name="state" column="state" type="java.lang.String"/>
       <property name="type" column="type" type="java.lang.String"/>
       <list name="referralSubType" table="referral_subtype" >
           <key column="id" />
           <list-index column="list_index" />
           <element type="string" column="subtype"/>
       </list>
   </class>
   <query name="getLocations">
               <![CDATA[
                       from test.Location location
                               where location.isVisible = true
                               order by location.location
  ]]>
</hibernate-mapping>

table location
"id","location","street","city","state","zip","hr_contact_email","is_visible"
1,"Syracuse, UT","add","Syracuse","UT","84075","email",1
2,"Murray, UT","add","Murray","UT","84107","email",1
12,"Henderson, NV","add","Henderson","NV","89014","email",1
14,"Summerlin, NV","add","Las Vegas","NV","89135","email",1

table referral_type
"id","state","type","list_index"
1,"UT","Internet",1
2,"UT","Referral",2
3,"NV","Newspaper",0
4,"NV","Internet",1
5,"NV","Referral",2

table referral_subtype
"id","subtype","list_index"
0,"Salt Lake Tribune",0
0,"Standard Examiner",1
0,"Daily Herald",2
0,"The Globe",3
0,"Deseret Morning News",4
0,"Utah Chronicle",5
0,"Other Publication (Specify)",6
1,"corp.com",0
1,"YahooHotJobs.com",1
1,"YourUtahJob.com",2
1,"Monster.com",3
1,"Craigslist.com",4
1,"Jobs.Utah.gov",5
1,"Other Website (Specify)",6
2,"CurrentEmployee",0
2,"Friend of Family",1
2,"Other (Specify",2

2008-06-12 12:59:56,565 DEBUG [http-8080-Processor24] jdbc.AbstractBatcher (AbstractBatcher.java:346) - select location0_.id as id5_, location0_.location as location5_, location0_.street as street5_, location0_.city as city5_, location0_.state as state5_, location0_.zip as zip5_, location0_.hr_contact_email as hr7_5_, location0_.is_visible as is8_5_ from location location0_ where location0_.is_visible=1 order by location0_.location
2008-06-12 12:59:56,572 DEBUG [http-8080-Processor24] jdbc.AbstractBatcher (AbstractBatcher.java:346) - select referralty0_.state as state1_, referralty0_.id as id1_, referralty0_.list_index as list4_1_, referralty0_.id as id6_0_, referralty0_.state as state6_0_, referralty0_.type as type6_0_ from referral_type referralty0_ where referralty0_.state=?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 9:02 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
Try with out where clause and see if some records or seen.. also make sure in sql console the generated hibernate sqls are able run and give you some values.

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject: Yes, the queries work fine
PostPosted: Sat Jun 14, 2008 10:02 am 
Newbie

Joined: Thu Jun 12, 2008 1:14 am
Posts: 4
nagkumar wrote:
Try with out where clause and see if some records or seen.. also make sure in sql console the generated hibernate sqls are able run and give you some values.


They work just fine when given state values from the locations table... just as you expect. There has to be something wrong in my mapping file...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 10:33 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
nope.. what is the record u see.. is this some related to case sensitivity etc..

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject: More info
PostPosted: Sat Jun 14, 2008 1:51 pm 
Newbie

Joined: Thu Jun 12, 2008 1:14 am
Posts: 4
nagkumar wrote:
nope.. what is the record u see.. is this some related to case sensitivity etc..


Thanks for looking at this. I'm glad you don't think my mapping file is hopeless.

For instance, when I load these objects using getHibernateTemplate().findByNamedQuery("getLocations");
I would get the location id 1 back without any ReferralTypes. As you can see there are records with state = 'UT' that should be loaded. I would rather see hibernate log the actual queries instead of the prepared statement so I can see the value of the field state in the sub query, but it doesn't seem to be available and I can't seem to get my mysql query log to work... I guess I'll work on that now...

At any rate, I am worried that it is using the ID or something to do the subquery instead of the state. Now writing this, maybe I should replace the UT in the state with 0 or something and see if it returns it...

Thanks for your help!


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.