I cannot persist my entity and I get the message above but only when I
use event listener. Does anybody know why? Here are the facts:
NHibernate 2.1, FluentNHibernate 1.0, Castle Dynamic proxy provider
Mapping for MetaProject:
public class MetaProjectMap : ClassMap<MetaProject>
{
public MetaProjectMap()
{
DefaultAccess.ReadOnlyPropertyThroughCamelCaseField
(CamelCasePrefix.Underscore);
Table("dnnSphere_Project");
Id(x => x.Id).Access.LowerCaseField
(Prefix.Underscore).GeneratedBy.HiLo("1").UnsavedValue(0); ;
Map(x => x.Name).Column("Name").Unique().Not.Nullable
().Length(50);
Map(x => x.Description).Column("Description").Length(50);
HasMany<MetaPackage>(x => x.MetaPackages).Table
("dnnSphere_Package").KeyColumn("Id")
.Inverse().LazyLoad().Cascade.AllDeleteOrphan()
.Access.ReadOnlyPropertyThroughCamelCaseField
(Prefix.Underscore)
.CollectionType
("dnnSphere.NHibernate.Collections.PersistentBagType`1
[[dnnSphere.Meta.Model.MetaPackage, dnnSphere.Meta]],
dnnSphere.NHibernate.Collections");
}
}
NHibernate config file:
<property
name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</property>
<property name="current_session_context_class">
web
</property>
<event type="save-<listener
class="dnnSphere.Meta.NHibernate.SaveOrUpdateEventListener,dnnSphere.Meta"/
>
<listener
class="NHibernate.Event.Default.DefaultUpdateEventListener,
NHibernate"/>
</event>
Code that I am testing this with:
ISession session = NHibernateHelper.Instance.GetCurrentSession();
try
{
session.BeginTransaction();
metaProject = MetaProject.Create();
metaProject.Name = txtName.Text;
metaProject.Description = txtDescription.Text;
session.SaveOrUpdate(metaProject);
session.Flush();
var n =
NHibernateHelper.Instance.SessionFactory.Statistics.EntityInsertCount;
session.Transaction.Commit();
}
catch (Exception ex)
{
session.Transaction.Rollback();
throw;
}
finally
{
session.Close();
}
Event listener:
public class SaveOrUpdateEventListener : ISaveOrUpdateEventListener
{
public void OnSaveOrUpdate(SaveOrUpdateEvent @event)
{
IPersistentObjectLifeCycle o = @event.Entity as
IPersistentObjectLifeCycle;
if (o != null)
{
o.OnSaveOrUpdate();
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---