-->
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.  [ 2 posts ] 
Author Message
 Post subject: db2 Failed to lazily initialize a collection
PostPosted: Wed May 24, 2006 10:26 am 
Newbie

Joined: Wed May 24, 2006 9:52 am
Posts: 5
I've faced a problem using DB2
I have two tables: ParentTable and ChildTable
----ParentTable-----------------------------------------
<id name="Id" column="ID" type="Int32">
<generator class="native">
</generator>
</id>
<property name="Name" column="&quot;Name&quot;" type="String" length="255" />

<set name="Children" cascade="delete-orphan" lazy="false" inverse="true">
<key column="&quot;Parent_Id&quot;"/>
<one-to-many class="DataLayer.User, DataLayer"/>
</set>


----ChildTable-----------------------------------------
<id name="Id" column="ID" type="Int32">
<generator class="native">
</generator>
</id>
<property name="Name" column="&quot;Name&quot;" type="String" length="255" />
<many-to-one name="Parent" class="DataLayer.Parent, DataLayer" column="&quot;Parent_Id&quot;" />
------------------------------

When the "Child" table is empty everything is ok
otherwise I get an exception
[NHibernate.ADOException] {NHibernate.ADOException} NHibernate.ADOException
"could not initialize collection: [DataLayer.Parent.Children#1]"

Does anybody knows whats wrong


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 11:57 pm 
Newbie

Joined: Wed May 24, 2006 9:52 am
Posts: 5
I would appreciate for a fast reply... this stuff is quite urgent for me and I still cannot find a solution
The fact is that this one-to-many construction was working perfectly with microsoft access. But when we migrated to DB2 v8.1.11.973 this problem occured.
I am not very experienced in NHibernate and I dot'n even know what is the reason of the failure :(



Maybe the information I gave was not full
so here is the database structure of my tables
-------------------------------------------------------------------------
--create table "Parent" (
"Name" VARCHAR(50) not null,
ID INTEGER not null
generated always as identity
);

ALTER TABLE "Parent" ADD CONSTRAINT ParentPK PRIMARY KEY ( ID) ;

create table "Child" (

"Name" VARCHAR(50) not null,
ID INTEGER not null
generated always as identity,
"Parent_Id" INTEGER not null
);

ALTER TABLE "Child" ADD CONSTRAINT ChildPK PRIMARY KEY ( ID) ;

alter table "Child"
add constraint "F_26_Ref" foreign key ("Parent_Id")
references "Node" (ID)
on delete cascade;

-----------------------------------------------------------------

Here is the full stack trace of my exception


at System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName)
at System.Data.OleDb.OleDbDataReader.GetOrdinal(String name)
at NHibernate.Driver.NHybridDataReader.GetOrdinal(String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Collection.AbstractCollectionPersister.ReadKey(IDataReader dr, ISessionImplementor session)
at NHibernate.Loader.Loader.ReadCollectionElement(Object optionalOwner, Object optionalKey, IDataReader rs, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object[] ids, IType[] types)
at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type)
at NHibernate.Loader.OneToManyLoader.Initialize(Object id, ISessionImplementor session)
at NHibernate.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session)


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