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: unable to serialize lazy loading collections over remoting
PostPosted: Fri Jul 07, 2006 4:10 am 
Newbie

Joined: Fri Jul 07, 2006 3:34 am
Posts: 1
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]


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.