Why am I getting: NHibernate.MappingException : No persister for: System.String

4,906 views
Skip to first unread message

Dave

unread,
Mar 15, 2011, 4:21:46 PM3/15/11
to fluent-n...@googlegroups.com
Pretty simple question.  Why does this exception get thrown when I call Save on my ISession?  

This is happening in a Unit test using FluentNHibernate 1.2 with NHibernate 3.0.

My class is really simple:

    public class Spooge
    {
        public virtual long Id { get; set; }
        public virtual string Name { get; set; }
    }

My mapping class is equally simple:

    public class SpoogeMapping : ClassMap<Spooge>
    {
        public SpoogeMapping()
        {
            Table("spooges");
            Id(x => x.Id)
                .GeneratedBy
                .Sequence("spooges_seq");
            Map(x => x.Name)
                .Column("name")
                .Not.Nullable();
        }
    }

I build my session factory like this:

sessionFactory = Fluently.Configure()
                .Database(connectionCfg)
                .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())
                                   .ExportTo("c:\\temp"))
                .ExposeConfiguration(x => x.SetProperty("current_session_context_class", "thread_static"))
                .BuildSessionFactory();

and the generated hbm.xml file looks like this:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true">
  <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Tx.Tests.Spooge, Tx.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="Spooges">
    <id name="Id" type="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Id" />
      <generator class="sequence">
        <param name="sequence">spooges_seq</param>
      </generator>
    </id>
    <property name="Name" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="name" not-null="true" />
    </property>
  </class>
</hibernate-mapping>

James Gregory

unread,
Mar 16, 2011, 5:52:02 AM3/16/11
to fluent-n...@googlegroups.com
I have no idea. Never seen that before.

Do you have any other mappings?
Can you create a failing test or example sln for us to take a look at?

Dave

unread,
Mar 16, 2011, 11:21:41 AM3/16/11
to fluent-n...@googlegroups.com

I have no other mappings in the project.  This project is my attempt at getting Tom Rathbone's Ninject Spring extension framework working with the latest version of Ninject but with NHibernate (using FluentNHibernate) instead of .NET ADO.

I have a solution that I can give you.  Where can I sent/put it?

James Gregory

unread,
Mar 16, 2011, 11:26:44 AM3/16/11
to fluent-n...@googlegroups.com
Email it to myself (ja...@jagregory.com)

Dave

unread,
Mar 17, 2011, 2:32:51 PM3/17/11
to fluent-n...@googlegroups.com
Problem solved.

I was passing the wrong object to the ISession.Save method.
Reply all
Reply to author
Forward
0 new messages