Hi Dan,

 

Finally got around to playing with this. Lazy loading appears to be working
fine, but having a problem when cascading a save from a parent to child
collection.

 

This is the scenario:

 

.         Header and Child Entities - Lazy

.         Header -< Child IList relationship - Lazy, Cascade:
AllDeleteOrphan.

.         List Form

o   Session using ConversationalScope

o   DataGrid populated with Header records.

.         Edit Form

o   No session.

o   DataGrid populated with Header.Detail records.

 

1.       App starts, List Form present itself populated with Header records
from database. The relationship to Child could be lazily loaded on this
form, but not always.

2.       User selects Record, clicks Edit button, Edit Form displays as
dialog.

a.       Header record is passed by value to the form.

b.      Child details populated via BindingList->BindingSource->DataGrid, no
problems.

3.       User clicks Save button, which calls Header.Save.

4.       Exception is thrown as below.

 

I use InPlaceConfigurationSource, so I made a small change to
DefaultDatabaseConfiguration to cater for the additional
CollectionTypeFactory configuration property. Otherwise this is a .net3.5
standard build of the source pulled from your Git a few weeks back.

 

After initialising AR, I made sure everything was still correct.



 

However, in ActiveRecordBase.InternalSave the call to
session.SaveOrUpdate(instance) throws a HibernateException.



 

Any ideas?

 

Regards

Nick

 

Nick,

For more information on configuring the ByteCode, please see the wiki:

 <http://docs.castleproject.org/Active%20Record.The-ByteCode.ashx>
http://docs.castleproject.org/Active%20Record.The-ByteCode.ashx

 

In addition to setting the ProxyFactory, as described in the wiki, you will
also need to set the CollectionTypeFactory.  In your configuration file, add
the following line:

<add key="collectiontype.factory_class"

value="Castle.ActiveRecord.ByteCode.CollectionTypeFactory,

Castle.ActiveRecord"/>

 

An example config section would look something like this:

<config>

    <add key="connection.driver_class"

value="NHibernate.Driver.SqlClientDriver"/>

   <add key="dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>

    <add key="connection.provider"

value="NHibernate.Connection.DriverConnectionProvider"/>

    <add key="connection.connection_string" value="Server=(local)
\sqlexpress;initial catalog=test;Integrated Security=SSPI" />

    <add key="proxyfactory.factory_class"

value="Castle.ActiveRecord.ByteCode.ProxyFactoryFactory,

Castle.ActiveRecord"/>

    <add key="collectiontype.factory_class"

value="Castle.ActiveRecord.ByteCode.CollectionTypeFactory,

Castle.ActiveRecord"/>

    <add key="query.factory_class"

value="NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory, NHibernate"/

> 

</config>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

<<image001.png>>

<<image002.png>>

Reply via email to