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.  [ 7 posts ] 
Author Message
 Post subject: Custom load-collection with Stored Procedure
PostPosted: Mon Nov 06, 2006 2:49 pm 
Newbie

Joined: Thu Aug 17, 2006 3:31 pm
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I am using a custom loader to load a collection using a Stored Procedure. The SQL executes just fine, data is returned from the sproc, the objects appear to be hydrated just fine, however the resulting IList is empty when I try to iterate it or get a .Count. No errors are thrown and everything else appears to be working normally. I tried lazy/non lazy, tried using a Set instead of a Bag, but nothing seems to be working.

[b]Hibernate version:[/b]
1.2.0.2001

[b]Mapping documents:[/b]
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="NHibernateSqlLazyLoad" namespace="NHibernateSqlLazyLoad">
<class name="InventoryItem" table="Price" mutable="false">
<composite-id>
<key-property name="SellerId" access="nosetter.camelcase-underscore" column="TradingPartnerId" />
<key-property name="Id" access="nosetter.camelcase-underscore" column="Part_Id" />
</composite-id>
<property name="Qualifier" column="Part_Qlfr" />
<property name="Name" column="Part_Numb" />

<bag name="Alternates" access="nosetter.camelcase-underscore" generic="true">
<key>
<column name="TradingPartnerId" />
<column name="Part_Id" />
</key>
<one-to-many class="InventoryItem" />
<loader query-ref="GetAlternateItems" />
</bag>
</class>

<sql-query name="GetAlternateItems">
<load-collection alias="alternateItem" role="InventoryItem.Alternates" />
EXEC GetAlternateItems ?, ?
</sql-query>
</hibernate-mapping>

[b]Code between sessionFactory.openSession() and session.close():[/b]
using (ISession session = _sessionFactory.OpenSession())
{
InventoryItem lookup = new InventoryItem(1031086, 1);
InventoryItem item = session.Get<InventoryItem>(lookup);
lookup = null;

Assert.AreEqual(2, item.Alternates.Count);
}

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]
Microsoft SQL Server 2000 SP4

[b]The generated SQL (show_sql=true):[/b]
EXEC GetAlternateItems @p0, @p1; @p0 = '1031086', @p1 = '1'

[b]Debug level Hibernate log excerpt:[/b]
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Impl.BatcherImpl - Opened Reader, open Readers :1
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Loader.Loader - result set contains (possibly empty) collection: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/1]
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Impl.SessionImpl - uninitialized collection: initializing
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Loader.Loader - processing result set
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Loader.Loader - result set row: 0
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,742 [6016] DEBUG NHibernate.Type.Int32Type - returning '3' as column: Part_Id
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - result row: NHibernateSqlLazyLoad.InventoryItem/3
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - Hydrating entity: NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.StringType - returning 'BRIG' as column: Part_Qlfr
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.StringType - returning '397222' as column: Part_Numb
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '3' as column: Part_Id
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - found row of collection: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Impl.SessionImpl - new collection: instantiating
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '3' as column: Part_Id
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Impl.SessionImpl - loading [InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Impl.SessionImpl - resolved object in session cache [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - result set row: 1
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.Int32Type - returning '6' as column: Part_Id
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - result row: NHibernateSqlLazyLoad.InventoryItem/6
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Loader.Loader - Hydrating entity: NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6
2006-11-06 11:36:42,758 [6016] DEBUG NHibernate.Type.StringType - returning 'BRIG' as column: Part_Qlfr
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Type.StringType - returning '695725' as column: Part_Numb
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Type.Int32Type - returning '6' as column: Part_Id
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Loader.Loader - found row of collection: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - new collection: instantiating
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Type.Int32Type - returning '1031086' as column: TradingPartnerId
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Type.Int32Type - returning '6' as column: Part_Id
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - loading [InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - attempting to resolve [InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - resolved object in session cache [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Loader.Loader - done processing result set (2 rows)
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.BatcherImpl - Closed Reader, open Readers :0
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands :0
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Loader.Loader - total objects hydrated: 2
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - resolving associations for: [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - returning loading collection:[NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - done materializing entity [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - resolving associations for: [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - returning loading collection:[NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - done materializing entity [NHibernateSqlLazyLoad.InventoryItem#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - 3 collections were found in result set
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - collection fully initialized: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/3]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - collection fully initialized: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/1]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - collection fully initialized: [NHibernateSqlLazyLoad.InventoryItem.Alternates#NHibernateSqlLazyLoad.InventoryItem/6]
2006-11-06 11:36:42,773 [6016] DEBUG NHibernate.Impl.SessionImpl - 3 collections initialized
2006-11-06 11:36:42,789 [6016] DEBUG NHibernate.Impl.SessionImpl - collection initialized
2006-11-06 11:36:42,789 [6016] DEBUG NHibernate.Loader.Loader - done entity load

Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 3:12 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Submit this to JIRA, including a simple complete test case, and I will investigate.


Top
 Profile  
 
 Post subject: JIRA Down?
PostPosted: Tue Nov 07, 2006 12:49 pm 
Newbie

Joined: Thu Aug 17, 2006 3:31 pm
Posts: 9
Has the JIRA been down for the past two days or is it just me?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 1:00 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Works just fine for me. What is the problem you are getting?


Top
 Profile  
 
 Post subject: Problem loading page - The Connection was Reset
PostPosted: Tue Nov 07, 2006 1:25 pm 
Newbie

Joined: Thu Aug 17, 2006 3:31 pm
Posts: 9
Get the above error in FF and a similar error in IE when navigating to:

http://jira.nhibernate.org/secure/

Can hit www.nhibernate.org just fine, svn no problem either. I presumed it was down but maybe something is wrong on my end.

-Bill


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 2:23 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Hmm, now I see the problem as well, I e-mailed Michael Third, our JIRA maintainer, hopefully it will be fixed soon.


Top
 Profile  
 
 Post subject: See NH-794
PostPosted: Wed Nov 08, 2006 12:00 pm 
Newbie

Joined: Thu Aug 17, 2006 3:31 pm
Posts: 9
See NH-794

http://jira.nhibernate.org/browse/NH-794


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