Hi,
I have a problem trying to access a lazy loading collection over remoting. I know that the xml serializer should trigger the collection to initialize itself (provided the session is open at the time) and that if i do not want this to happen i should null the collection first.
I'm experiencing a different problem where my collection should be valid on the client side, but instead (using the Visual Studio Watch window to test my simple console applications) I get LazyInitializationException. The session exists in a member field of a class on the server, which remains open until the client calls a remotable method CloseSession() and is definately still open at the time the lazy collection is access through the debugger.
can anyone shed some light on this problem?
thanks,
tristan
Hibernate version:
nHibernate 1.0.2.0
Mapping documents:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="TestHibernate.BusinessLayer.Asset, TestHibernate" table="asset">
<id name="ID" column="ID" >
<generator class="assigned" />
</id>
<!-- Map properties I'd like to persist/fetch,
assume column = propery name,
and type is determined by reflection -->
<property name="Status" column="status"></property>
<!-- AssetData collection, pull asset data but,
loading lazy to minimize load time, resource usage. -->
<set name="Data" cascade="all" lazy="true">
<key column="asset_id" />
<one-to-many class="TestHibernate.BusinessLayer.AssetData, TestHibernate" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Code:
class AssetMgr
{
ISession session;
public IList GetAssets()
{
IList assets = null;
ITransaction tx = null;
session = null;
try
{
session = factory.OpenSession();
tx = session.BeginTransaction();
assets = session.Find("from TestHibernate.BusinessLayer.Asset as asset");
// session.Close();
}
catch (Exception ex)
{
Console.Write(ex);
tx.Rollback();
session.Close();
// handle exception.
}
return assets;
}
Full stack trace of any exception that occurs:Name and version of the database you are using:SQL Server Express 2005
The generated SQL (show_sql=true):Debug level Hibernate log excerpt:[/code]