Enable debug-logging from NHibernate and see if the logs from the
configuration and build session factory steps gives some help.

/Oskar


2014-06-23 14:49 GMT+02:00 Eric Downey <edowne...@gmail.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
>
>  --
>
> ---
> 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-development+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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-development+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to