-->
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: Collections in Projections ?
PostPosted: Wed Sep 14, 2005 4:12 pm 
Newbie

Joined: Thu Jun 02, 2005 11:20 am
Posts: 9
Hibernate version: 3.0.5

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

AliasToBeanResultTransformer resultTransformer = AliasToBeanResultTransformer(Content.class);
String[] properties = pSession.getSessionFactory().getClassMetadata(Content.class).getPropertyNames();
criteria.setProjection(Projections.distinct(buildProjection(properties)));
criteria.setResultTransformer(resultTransformer);

// build projections just makes a projection list from the properties.

for some reason, none of the Content.class's proxied collections are being initialiezd. the many-to-one works properly, but none of the Sets or Lists are created. They're just null.

After looking at the SQL and walking through it w/ the debugger a bit, it just seems to ignore the collection properties.

I need to have these proxies available so that I can access this information!

Name and version of the database you are using:

SQL SERVER 2k

The generated SQL (show_sql=true):
select distinct this_.content_type_id as y0_, this_.title as y1_, this_.summary as y2_, this_.branch as y3_, this_.relative_path as y4_, thi
s_.image_path as y5_, this_.creation_date as y6_, this_.expiration_date as y7_, this_.last_update_date as y8_, this_.last_update_user as y9_, this_.content_id as y10_, this_.content_id as y11_, this_.content_id as y12_, this_.content_id as y13_ from iwsc_content this_ left outer join iwsc_news this_1_ on this_.content_id=this_1_.content_id left outer join iwsc_event this_2_ on
this_.content_id=this_2_.content_id left outer join iwsc_document this_3_ on this_.content_id=this_3_.content_id inner join iwsc_content_category categories3_ on this_.content_id=categories3
_.content_id inner join iwsc_category category1_ on categories3_.category_id=category1_.category_id where (this_.expiration_date is null or this_.expiration_date>?) and category1_.category_i
d in (?, ?, ?, ?) and this_.branch in (?)

Debug level Hibernate log excerpt:

2005-09-14 15:58:15,468 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-09-14 15:58:15,468 DEBUG org.hibernate.SQL - select distinct this_.content_type_id as y0_, this_.title as y1_, this_.summary as y2_, this_.branch as y3_, this_.relative_path as y4_, thi
s_.image_path as y5_, this_.creation_date as y6_, this_.expiration_date as y7_, this_.last_update_date as y8_, this_.last_update_user as y9_, this_.content_id as y10_, this_.content_id as y1
1_, this_.content_id as y12_, this_.content_id as y13_ from iwsc_content this_ left outer join iwsc_news this_1_ on this_.content_id=this_1_.content_id left outer join iwsc_event this_2_ on
this_.content_id=this_2_.content_id left outer join iwsc_document this_3_ on this_.content_id=this_3_.content_id inner join iwsc_content_category categories3_ on this_.content_id=categories3
_.content_id inner join iwsc_category category1_ on categories3_.category_id=category1_.category_id where (this_.expiration_date is null or this_.expiration_date>?) and category1_.category_i
d in (?, ?, ?, ?) and this_.branch in (?)
2005-09-14 15:58:15,468 DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.TimestampType - binding '2005-09-14 12:00:00' to parameter: 1
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.LongType - binding '100000005' to parameter: 2
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.LongType - binding '100000010' to parameter: 3
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.LongType - binding '100000015' to parameter: 4
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.LongType - binding '100000020' to parameter: 5
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - binding '/default/main/solutions/SalesSolution' to parameter: 6
2005-09-14 15:58:15,468 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
2005-09-14 15:58:15,468 DEBUG org.hibernate.loader.Loader - processing result set
2005-09-14 15:58:15,468 DEBUG org.hibernate.loader.Loader - result set row: 0
2005-09-14 15:58:15,468 DEBUG org.hibernate.loader.Loader - result row:
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.LongType - returning '100000035' as column: y0_
2005-09-14 15:58:15,468 DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [com.interwoven.solutions.model.category.ContentType#100000035]
2005-09-14 15:58:15,468 DEBUG org.hibernate.event.def.DefaultLoadEventListener - creating new proxy for entity
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning 'Some Brochure' as column: y1_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning 'Summary of the Brochure' as column: y2_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning '/default/main/solutions/SalesSolution' as column: y3_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning 'templatedata/SalesSolution/General/data/product_brochure_1.xml' as column: y4_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning null as column: y5_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.TimestampType - returning '2005-08-12 00:00:00' as column: y6_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.TimestampType - returning '2006-08-12 00:00:00' as column: y7_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.TimestampType - returning null as column: y8_
2005-09-14 15:58:15,468 DEBUG org.hibernate.type.StringType - returning 'test\shanon' as column: y9_

yes, that's it... where did y10-y13 go? I don't know. Annd, the resulting array just has nulls for the value instead of a CGLIB proxy...

any help is appreciated.

-shanon


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.