NHibernate.MappingException No persister

1,246 views
Skip to first unread message

Eric Downey

unread,
Jun 23, 2014, 8:49:44 AM6/23/14
to nhibernate-...@googlegroups.com
So, as the title suggests I keep getting this error for all of my objects (that I've unit tested so far).  I'm upgrading from 2.2 to 3.3.x and I'm using Entity Developer from Devart to generate everything.  This is the first app I've started with 3.3.x - I've been using 2.2 very happily for several years but I think it's time to move forward as it were.  If I can get it to work it would be very very cool indeed.  Anyway, I've been beating my head against a wall for days now trying to figure out where things are going awry.  I checked all the usual suspects that I've had issues with before: Embedded resource, not making stuff public, etc.  Here's the code I genned for my role object.

using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace HSC.Domain
{

    public partial class Role
    {
    }
}

//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using NHibernate template.
// Code is generated on: 6/20/2014 2:27:21 PM
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace HSC.Domain
{

    /// <summary>
    /// There are no comments for HSC.Domain.Role, HSC.Domain in the schema.
    /// </summary>
    [DataContract(IsReference = true)]
    public partial class Role {
    
        #region Extensibility Method Definitions
        
        /// <summary>
        /// There are no comments for OnCreated in the schema.
        /// </summary>
        partial void OnCreated();
        
        #endregion
        /// <summary>
        /// There are no comments for Role constructor in the schema.
        /// </summary>
        public Role()
        {
            this.Users = new Iesi.Collections.Generic.HashedSet<User>();
            OnCreated();
        }

    
        /// <summary>
        /// There are no comments for RoleId in the schema.
        /// </summary>
        [DataMember(Order=1)]
        public virtual System.Guid RoleId
        {
            get;
            set;
        }

    
        /// <summary>
        /// There are no comments for RoleName in the schema.
        /// </summary>
        [DataMember(Order=2)]
        public virtual string RoleName
        {
            get;
            set;
        }

    
        /// <summary>
        /// There are no comments for ApplicationName in the schema.
        /// </summary>
        [DataMember(Order=3)]
        public virtual string ApplicationName
        {
            get;
            set;
        }

    
        /// <summary>
        /// There are no comments for Users in the schema.
        /// </summary>
        [DataMember(Order=4, EmitDefaultValue=false)]
        public virtual Iesi.Collections.Generic.ISet<User> Users
        {
            get;
            set;
        }
    }

}

//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using the template for generating Repositories and a Unit of Work for NHibernate model.
// Code is generated on: 6/20/2014 2:27:21 PM
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;

namespace HSC.Repository.Interfaces
{
    public partial interface IRoleRepository : IRepository<HSC.Domain.Role>
    {
        ICollection<HSC.Domain.Role> GetAll();
        HSC.Domain.Role GetByKey(System.Guid _RoleId);
    }
}

//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using the template for generating Repositories and a Unit of Work for NHibernate model.
// Code is generated on: 6/17/2014 8:49:12 AM
//
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;

namespace HSC.Repository.Interfaces
{
    public partial interface IRoleRepository
    {
    }
}

//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using the template for generating Repositories and a Unit of Work for NHibernate model.
// Code is generated on: 6/20/2014 2:27:21 PM
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------
using System;
using System.Linq;
using System.Collections.Generic;
using NHibernate;
using NHibernate.Linq;
using HSC.Repository.Interfaces;

namespace HSC.Repository.Repositories
{
    public partial class RoleRepository : NHibernateRepository<HSC.Domain.Role>, IRoleRepository
    {
        public RoleRepository(ISession session) : base(session)
        {
        }

        public virtual ICollection<HSC.Domain.Role> GetAll()
        {
            return session.CreateQuery(string.Format("from Role")).List<HSC.Domain.Role>();
        }

        public virtual HSC.Domain.Role GetByKey(System.Guid _RoleId)
        {
            return session.Get<HSC.Domain.Role>(_RoleId);
        }
    }
}

//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using the template for generating Repositories and a Unit of Work for NHibernate model.
// Code is generated on: 6/10/2014 3:53:37 PM
//
//------------------------------------------------------------------------------

using System.Collections.Generic;
using System.Text.RegularExpressions;
using HSC.Domain;

namespace HSC.Repository.Repositories
{
    public partial class RoleRepository
    {
        public Role FindByRolenameApplication(string roleName, string applicationName)
        {
            var _roles = NHibernateSessionProvider.GetSession().CreateQuery(
                "FROM Role c WHERE c.RoleName = :RoleName AND c.ApplicationName = :ApplicationName")
                .SetString("RoleName", roleName).SetString("ApplicationName", applicationName).List<Role>();

            return (_roles.Count.Equals(1) ? _roles[0] : null);
        }

        public IList<User> FindLikeUsernameRolenameApplication(string username, string roleName, string applicationName)
        {
            var _roles = NHibernateSessionProvider.GetSession().CreateQuery(
                "FROM Role as roles " +
                "WHERE " +
                " roles.RoleName = :RoleName AND " +
                " roles.ApplicationName = :ApplicationName")
                .SetString("RoleName", roleName).SetString("ApplicationName", applicationName).List<Role>();

            var _users = new List<User>();

            if (_roles.Count != 1)
            {
                var _hasWildCard = false;

                if (username.Contains("%")) _hasWildCard = true;

                foreach (var _user in _roles[0].Users)
                {
                    if (_hasWildCard)
                    {
                        if (Regex.Match(_user.UserName, username).Success)
                        {
                            _users.Add(_user);
                        }
                    }
                    else
                    {
                        if (_user.UserName == username)
                            _users.Add(_user);
                    }
                }
            }

            return _users;
        }

        public IList<Role> FindByApplication(string applicationName)
        {
            var _roles = NHibernateSessionProvider.GetSession().CreateQuery(
                "FROM Role c WHERE c.ApplicationName = :ApplicationName")
                .SetString("ApplicationName", applicationName).List<Role>();

            return _roles;
        }

        public Role FindByName(string roleName)
        {
            var _roles = NHibernateSessionProvider.GetSession().CreateQuery(
                "FROM Role c WHERE c.RoleName = :RoleName")
                .SetString("RoleName", roleName).List<Role>();

            return _roles.Count > 0 ? _roles[0] : null;
        }

    }
}

using System.Transactions;
using HSC.Domain;
using HSC.Repository.Repositories;
using NHibernate.Cfg;
using NUnit.Framework;

namespace HSC.UnitTesting
{
    [TestFixture]
    public class RoleTests
    {
        private TransactionScope _scope;

        [SetUp]
        public void SetUp()
        {
            _scope = new TransactionScope(TransactionScopeOption.RequiresNew);
        }

        [TearDown]
        public void TearDown()
        {
            _scope.Dispose();
        }

        [Test]
        public void CanWeCreateARoll()
        {
            var _role = CreateARole();

            new RoleRepository(NHibernateSessionProvider.GetSession()).Add(_role);

            var _found = new RoleRepository(NHibernateSessionProvider.GetSession()).GetByKey(_role.RoleId);

            Assert.AreEqual(_role.RoleName, _found.RoleName);
        }

        public static Role CreateARole()
        {
            var _role = new Role { ApplicationName = "HSC", RoleName = "Admin" };

            return _role;
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="HSC.Domain" namespace="HSC.Domain" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Role" table="Roles">
    <id name="RoleId" type="Guid">
      <column name="RoleId" not-null="true" />
      <generator class="assigned" />
    </id>
    <property name="RoleName" type="String">
      <column name="RoleName" not-null="true" />
    </property>
    <property name="ApplicationName" type="String">
      <column name="ApplicationName" not-null="true" />
    </property>
    <set name="Users" table="Users_Roles" generic="true">
      <key>
        <column name="RoleId" not-null="true" />
      </key>
      <many-to-many class="User" fetch="join">
        <column name="UserId" not-null="true" />
      </many-to-many>
    </set>
  </class>
</hibernate-mapping>

NHibernate.MappingException : No persister for: HSC.Domain.Role
   at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName) in p:\nhibernate-core\src\NHibernate\Impl\SessionFactoryImpl.cs: line 473
   at NHibernate.Impl.SessionImpl.GetEntityPersister(String entityName, Object obj) in p:\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs: line 2787
   at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) in p:\nhibernate-core\src\NHibernate\Event\Default\AbstractSaveEventListener.cs: line 107
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs: line 162
   at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Event\Default\DefaultSaveEventListener.cs: line 27
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs: line 148
   at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Event\Default\DefaultSaveEventListener.cs: line 21
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs: line 53
   at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) in p:\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs: line 2673
   at NHibernate.Impl.SessionImpl.Save(Object obj) in p:\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs: line 485
   at HSC.Repository.Repositories.NHibernateRepository`1.Add(T entity) in NHibernateRepository.cs: line 43
   at HSC.UnitTesting.RoleTests.CanWeCreateARoll() in RoleTests.cs: line 31

Oskar Berggren

unread,
Jun 23, 2014, 11:17:57 AM6/23/14
to nhibernate-...@googlegroups.com
Enable debug-logging from NHibernate and see if the logs from the configuration and build session factory steps gives some help.

/Oskar


--

---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Downey

unread,
Jun 23, 2014, 12:06:24 PM6/23/14
to nhibernate-...@googlegroups.com
Okdoke.  Just turned on log4net and go the following.  Didn't see anything that looked like an error specifically or even where it got hung up.  But I'm not an NHibernate expert either ;)

2014-06-23 11:58:56,744 INFO NHibernate 3.3.1.4000 (3.3.3.GA)
2014-06-23 11:58:57,306 INFO Bytecode provider name : lcg
2014-06-23 11:58:57,308 INFO Using reflection optimizer
2014-06-23 11:58:57,320 DEBUG connection.driver_class=NHibernate.Driver.SqlClientDriver
2014-06-23 11:58:57,321 DEBUG connection.connection_string=Data Source=DOT6ZF85V1\MSSQLSERVERR2;Initial Catalog=HSC;Integrated Security=True;MultipleActiveResultSets=True
2014-06-23 11:58:57,322 DEBUG adonet.batch_size=100
2014-06-23 11:58:57,323 DEBUG show_sql=true
2014-06-23 11:58:57,323 DEBUG dialect=NHibernate.Dialect.MsSql2008Dialect
2014-06-23 11:58:57,324 DEBUG max_fetch_depth=true
2014-06-23 11:58:57,324 DEBUG command_timeout=60
2014-06-23 11:58:57,325 DEBUG query.substitutions=true 1, false 0, yes 'Y', no 'N'
2014-06-23 11:58:57,325 DEBUG current_session_context_class=web
2014-06-23 11:58:57,326 DEBUG hbm2ddl.auto=update
2014-06-23 11:58:57,326 DEBUG generate_statistics=true
2014-06-23 11:58:57,327 DEBUG <-HSC.Domain
2014-06-23 11:58:57,328 INFO Searching for mapped documents in assembly: HSC.Domain
2014-06-23 11:58:57,330 WARN No mapped documents found in assembly: HSC.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
2014-06-23 11:58:57,331 DEBUG properties: System.Collections.Generic.Dictionary`2[System.String,System.String]
2014-06-23 11:58:57,335 INFO checking mappings queue
2014-06-23 11:58:57,336 INFO processing one-to-many association mappings
2014-06-23 11:58:57,337 INFO processing one-to-one association property references
2014-06-23 11:58:57,337 INFO processing foreign key constraints
2014-06-23 11:58:57,338 INFO processing filters (second pass)
2014-06-23 11:58:57,383 INFO Using dialect: NHibernate.Dialect.MsSql2008Dialect
2014-06-23 11:58:57,445 INFO Using dialect: NHibernate.Dialect.MsSql2008Dialect
2014-06-23 11:58:57,488 INFO Using dialect defined converter
2014-06-23 11:58:57,490 INFO Generate SQL with comments: disabled
2014-06-23 11:58:57,491 INFO Configuring ConnectionProvider
2014-06-23 11:58:57,493 INFO setting ADO.NET command timeout to 60 seconds
2014-06-23 11:58:57,495 INFO Transaction factory: NHibernate.Transaction.AdoNetWithDistributedTransactionFactory
2014-06-23 11:58:57,496 INFO Optimize cache for minimal puts: False
2014-06-23 11:58:57,496 INFO Connection release mode: auto
2014-06-23 11:58:57,497 INFO Default batch fetch size: 1
2014-06-23 11:58:57,498 INFO echoing all SQL to stdout
2014-06-23 11:58:57,498 INFO Statistics: enabled
2014-06-23 11:58:57,499 INFO Deleted entity synthetic identifier rollback: disabled
2014-06-23 11:58:57,500 INFO Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
2014-06-23 11:58:57,502 INFO Query language substitutions: {'true'='1', 'false'='0', 'yes'=''Y'', 'no'=''N''}
2014-06-23 11:58:57,503 INFO cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2014-06-23 11:58:57,506 INFO Order SQL inserts for batching: enabled
2014-06-23 11:58:57,506 DEBUG Wrap result sets: disabled
2014-06-23 11:58:57,507 INFO Batcher factory: NHibernate.AdoNet.SqlClientBatchingBatcherFactory, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2014-06-23 11:58:57,508 INFO Default entity-mode: Poco
2014-06-23 11:58:57,509 INFO Named query checking : enabled
2014-06-23 11:58:57,531 INFO building session factory
2014-06-23 11:58:57,533 DEBUG Session factory constructed with filter configurations : {}
2014-06-23 11:58:57,534 DEBUG instantiating session factory with properties: {'use_reflection_optimizer'='True', 'bytecode.provider'='lcg', 'connection.driver_class'='NHibernate.Driver.SqlClientDriver', 'connection.connection_string'='Data Source=DOT6ZF85V1\MSSQLSERVERR2;Initial Catalog=HSC;Integrated Security=True;MultipleActiveResultSets=True', 'adonet.batch_size'='100', 'show_sql'='true', 'dialect'='NHibernate.Dialect.MsSql2008Dialect', 'max_fetch_depth'='true', 'command_timeout'='60', 'query.substitutions'='true 1, false 0, yes 'Y', no 'N'', 'current_session_context_class'='web', 'hbm2ddl.auto'='update', 'generate_statistics'='true'}
2014-06-23 11:58:57,536 DEBUG Obtaining IDbConnection from Driver
2014-06-23 11:58:57,868 DEBUG Closing connection
2014-06-23 11:58:57,877 DEBUG initializing class SessionFactoryObjectFactory
2014-06-23 11:58:57,878 DEBUG registered: 8555a384aef84e4b864c7642e7a94f38(unnamed)
2014-06-23 11:58:57,879 INFO no name configured
2014-06-23 11:58:57,879 DEBUG Instantiated session factory
2014-06-23 11:58:57,881 INFO Using dialect: NHibernate.Dialect.MsSql2008Dialect
2014-06-23 11:58:57,883 INFO Running hbm2ddl schema update
2014-06-23 11:58:57,901 INFO fetching database metadata
2014-06-23 11:58:57,902 INFO Configuring ConnectionProvider
2014-06-23 11:58:57,903 INFO setting ADO.NET command timeout to 60 seconds
2014-06-23 11:58:57,903 DEBUG Obtaining IDbConnection from Driver
2014-06-23 11:58:57,907 INFO updating schema
2014-06-23 11:58:57,911 INFO checking mappings queue
2014-06-23 11:58:57,912 INFO processing one-to-many association mappings
2014-06-23 11:58:57,913 INFO processing one-to-one association property references
2014-06-23 11:58:57,913 INFO processing foreign key constraints
2014-06-23 11:58:57,914 INFO processing filters (second pass)
2014-06-23 11:58:57,916 INFO schema update complete
2014-06-23 11:58:57,917 DEBUG Closing connection
2014-06-23 11:58:57,923 DEBUG Checking 0 named HQL queries
2014-06-23 11:58:57,923 DEBUG Checking 0 named SQL queries
2014-06-23 11:58:57,939 DEBUG [session-id=c2f375df-f311-486d-9fa8-6b55c1727e51] opened session at timestamp: 635391215379, for session factory: [/8555a384aef84e4b864c7642e7a94f38]
2014-06-23 11:58:57,943 DEBUG enlisted into DTC transaction: Serializable
2014-06-23 11:58:57,948 DEBUG Begin (Unspecified)
2014-06-23 11:58:57,949 DEBUG Obtaining IDbConnection from Driver
2014-06-23 11:58:57,957 DEBUG saving transient instance
2014-06-23 11:58:57,963 DEBUG IDbTransaction disposed.
2014-06-23 11:58:57,964 DEBUG transaction completion
2014-06-23 11:58:57,965 DEBUG aggressively releasing database connection
2014-06-23 11:58:57,966 DEBUG Closing connection
2014-06-23 11:58:57,976 DEBUG transaction completion
2014-06-23 11:58:57,991 DEBUG aggressively releasing database connection
2014-06-23 11:58:57,992 DEBUG rolled back DTC transaction
2014-06-23 11:58:57,998 DEBUG transaction completion
2014-06-23 11:58:57,999 DEBUG aggressively releasing database connection
 

Oskar Berggren

unread,
Jun 23, 2014, 1:10:49 PM6/23/14
to nhibernate-...@googlegroups.com
2014-06-23 18:06 GMT+02:00 Eric Downey <edow...@gmail.com>:
Okdoke.  Just turned on log4net and go the following.  Didn't see anything that looked like an error specifically or even where it got hung up.  But I'm not an NHibernate expert either ;)

2014-06-23 11:58:56,744 INFO NHibernate 3.3.1.4000 (3.3.3.GA)
2014-06-23 11:58:57,306 INFO Bytecode provider name : lcg
2014-06-23 11:58:57,308 INFO Using reflection optimizer
2014-06-23 11:58:57,320 DEBUG connection.driver_class=NHibernate.Driver.SqlClientDriver
2014-06-23 11:58:57,321 DEBUG connection.connection_string=Data Source=DOT6ZF85V1\MSSQLSERVERR2;Initial Catalog=HSC;Integrated Security=True;MultipleActiveResultSets=True
2014-06-23 11:58:57,322 DEBUG adonet.batch_size=100
2014-06-23 11:58:57,323 DEBUG show_sql=true
2014-06-23 11:58:57,323 DEBUG dialect=NHibernate.Dialect.MsSql2008Dialect
2014-06-23 11:58:57,324 DEBUG max_fetch_depth=true
2014-06-23 11:58:57,324 DEBUG command_timeout=60
2014-06-23 11:58:57,325 DEBUG query.substitutions=true 1, false 0, yes 'Y', no 'N'
2014-06-23 11:58:57,325 DEBUG current_session_context_class=web
2014-06-23 11:58:57,326 DEBUG hbm2ddl.auto=update
2014-06-23 11:58:57,326 DEBUG generate_statistics=true
2014-06-23 11:58:57,327 DEBUG <-HSC.Domain
2014-06-23 11:58:57,328 INFO Searching for mapped documents in assembly: HSC.Domain
2014-06-23 11:58:57,330 WARN No mapped documents found in assembly: HSC.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

It does confirm that it looks in an assembly but doesn't find anything. So I guess it's back to triple-checking the initialization logic and resources, and that the correct files are used during execution.

/Oskar
 


Eric Downey

unread,
Jun 23, 2014, 2:31:27 PM6/23/14
to nhibernate-...@googlegroups.com
Yeah, that's what I did all last week - literally.  Can't figure out for the life of me what I'm missing (hence all of the code I pasted in...)

Ricardo Peres

unread,
Jun 24, 2014, 4:52:38 AM6/24/14
to nhibernate-...@googlegroups.com
Are the .hbm.xml files being compiled as Resources? They must be... Check the file properties in Visual Studio.

RP

Eric Downey

unread,
Jun 24, 2014, 8:20:19 AM6/24/14
to nhibernate-...@googlegroups.com
Thanks, yeah I've been bitten by that one before.  I've checked and rechecked that one - in fact that was the first thing I checked.


--

---
You received this message because you are subscribed to a topic in the Google Groups "nhibernate-development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhibernate-development/NKSLCV3gemY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhibernate-develo...@googlegroups.com.

Ricardo Peres

unread,
Jun 24, 2014, 8:24:32 AM6/24/14
to nhibernate-...@googlegroups.com
OK, and the mapping files end with .hbm.xml and have the name of the full class that they refer to? Like HSC.Domain.Role.hbm.xml?

RP
To unsubscribe from this group and all its topics, send an email to nhibernate-development+unsub...@googlegroups.com.

Eric Downey

unread,
Jun 24, 2014, 8:42:21 AM6/24/14
to nhibernate-...@googlegroups.com
They do end with .hbm.xml but I didn't know it needed the full class name as the file name.  I'll try that - thanks!


To unsubscribe from this group and all its topics, send an email to nhibernate-develo...@googlegroups.com.

Eric Downey

unread,
Jun 24, 2014, 8:43:15 AM6/24/14
to nhibernate-...@googlegroups.com
Just tried modifying the file name with HSC.Domain. but didn't help.  I even tried putting that on the <class  name="" in the hbm file and that didn't do it either.  Very perplexing...

Eric Downey

unread,
Jun 24, 2014, 10:40:47 AM6/24/14
to nhibernate-...@googlegroups.com
Tried renaming the files as suggested but that didn't work.  Then I thought maybe I need the fully qualified name in the <class name="" in the hbm file but that didn't do it either.  Very perplexing.  99% of the code that I pasted in the original post is actually auto-generated from Devart's Entity Developer IDE.  I really want this to work 'cause it would make my life sssoooo much easier.

Oskar Berggren

unread,
Jun 24, 2014, 11:20:09 AM6/24/14
to nhibernate-...@googlegroups.com
How are you configuring nhibernate?

/Oskar


2014-06-23 20:31 GMT+02:00 Eric Downey <edow...@gmail.com>:
Yeah, that's what I did all last week - literally.  Can't figure out for the life of me what I'm missing (hence all of the code I pasted in...)

--

---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.

Eric Downey

unread,
Jun 24, 2014, 12:39:18 PM6/24/14
to nhibernate-...@googlegroups.com
Here's what's in my app.config file for NHibernate:

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">
        Data Source=DOT6ZF85V1\MSSQLSERVERR2;Initial Catalog=HSC;Integrated Security=True;MultipleActiveResultSets=True
      </property>
      <property name="adonet.batch_size">100</property>
      <property name="show_sql">false</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="max_fetch_depth">true</property>
      <property name="command_timeout">60</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <property name="current_session_context_class">web</property>
      <property name="show_sql">true</property>
      <property name="hbm2ddl.auto">update</property>
      <property name="generate_statistics">true</property>
      <mapping assembly="HSC.Domain"/>
    </session-factory>
  </hibernate-configuration>
 

Richard Wilde

unread,
Jun 24, 2014, 12:52:05 PM6/24/14
to nhibernate-...@googlegroups.com
Does HSC.Domain assembly contain the *.hbm.xml files as embedded resources?

Sent from my Windows Phone

From: Eric Downey
Sent: ‎24/‎06/‎2014 17:41
To: nhibernate-...@googlegroups.com
Subject: Re: [nhibernate-development] Re: NHibernate.MappingException No persister

--

Eric Downey

unread,
Jun 24, 2014, 1:50:56 PM6/24/14
to nhibernate-...@googlegroups.com
No, HSC.Domain points to all of my poco classes.  The hbm files are located in HSC.Repository.MappingFiles.  In my Nhibernate 2.2 production website I use TSICS.Domain in the assembly tag in my web.config/app.config and everything works fine (in my test app for NHibernate v3 I'm using HSC.Domain as the domain name).

Ricardo Peres

unread,
Jun 24, 2014, 1:57:49 PM6/24/14
to nhibernate-...@googlegroups.com
He said so.
Eric: what about the .NET code?
Are you doing a Configuration.Configure() ?

RP
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-development+unsub...@googlegroups.com.

Eric Downey

unread,
Jun 24, 2014, 2:08:55 PM6/24/14
to nhibernate-...@googlegroups.com
Yeah,

This is the code that entity developer genned up to provide a session:

//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using the template for generating Repositories and a Unit of Work for NHibernate model.
// Code is generated on: 6/20/2014 2:27:21 PM
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------
using NHibernate;
using NHibernate.Cfg;

namespace HSC.Repository.Repositories
{
    public class NHibernateSessionProvider
    {

        private static Configuration configuration;
        private static ISessionFactory sessionFactory;

        private NHibernateSessionProvider()
        {
        }

        public static Configuration Configuration
        {
            get
            {
                if (configuration == null)
                {
                    configuration = new Configuration();
                    configuration.Configure();
                }
                return configuration;
            }
        }

        public static ISessionFactory SessionFactory
        {
            get
            {
                if (sessionFactory == null)
                {
                    sessionFactory = Configuration.BuildSessionFactory();
                }
                return sessionFactory;
            }
        }

        public static ISession GetSession()
        {

            return SessionFactory.OpenSession();
        }
    }
}

Stephen Bohlen

unread,
Jun 24, 2014, 2:12:06 PM6/24/14
to nhibernate-development
I'd like to recommend that further discussion on this topic be moved to the NHUSERS forum which is more appropriate for its content.

--

---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.

Eric Downey

unread,
Jun 24, 2014, 2:15:55 PM6/24/14
to nhibernate-...@googlegroups.com
If you look at my code listing at the top of the post you'll see my unit test where I pass a session into the RoleRepository.Add function.  The GetSession invariably calls the Configuration.Configure (although to be certain I just stepped through it to verify).

Eric Downey

unread,
Jun 24, 2014, 2:18:17 PM6/24/14
to nhibernate-...@googlegroups.com
Okdoke, that's fine with me.  Do I move it or does an admin have to do that?

P.S. Steve, enjoyed your talk on SOLID at code camp last weekend ;)

sbo...@gmail.com

unread,
Jun 24, 2014, 2:23:51 PM6/24/14
to nhibernate-development
There's (sadly) no mechanism for moving a thread from one discussion group to another on Google groups.  The best way to 'move’ it is just for you to copy-paste the entirety of this email thread into a brand new post on the NHUSERS group.

(happy you enjoyed the talk last weekend, BTW <g>)
 
-Steve B.

--
Reply all
Reply to author
Forward
0 new messages