class is not mapped error

715 views
Skip to first unread message

Steve Lyle

unread,
Sep 1, 2016, 11:51:37 AM9/1/16
to nhusers
Can you tell me WHAT is not mapped?
How do you map it?

this is the error:

Server Error in '/' Application.

vDoors is not mapped [from vDoors]

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: vDoors is not mapped [from vDoors]

Source Error: 
[QuerySyntaxException: Tko.SmartMoves.Modules.Operations.Data.vDoors is not mapped [from vDoors]]
   NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.RequireClassPersister(String name) in c:\...\nhibernate-core-master\src\NHibernate\Hql\Ast\ANTLR\SessionFactoryHelperExtensions.cs:228
   NHibernate.Hql.Ast.ANTLR.Tree.FromElementFactory.AddFromElement() in c:\...\nhibernate-core-master\src\NHibernate\Hql\Ast\ANTLR\Tree\FromElementFactory.cs:82
  



This is the code (all 4 qry's yield the same result):
            var cfg = new Configuration();
            cfg.Configure();  // CONFIG FILE IS IN THE WEB SITE'S BIN FOLDER
            ISessionFactory sesFactory = cfg.BuildSessionFactory();
            var ses = sesFactory.OpenSession();
            // FAILS 
            //var qry = ses.CreateQuery("select ParentZoneRecid, ParentZone, ParentZoneEnabled, Zone, ZoneStatus, ZoneEnabled, GenericRecid, GenericEntity, GenericName, GenericEnabled, GenericType from vDoors");
            //var qry = ses.CreateQuery("select ParentZoneRecid, ParentZone, ParentZoneEnabled, Zone, ZoneStatus, ZoneEnabled, GenericRecid, GenericEntity, GenericName, GenericEnabled, GenericType from Tko.SmartMoves.Modules.Operations.Data.vDoors");
            //var qry = ses.CreateQuery("select r from Tko.SmartMoves.Modules.Operations.Data.vDoors r");
            var qry = ses.CreateQuery("from vDoors");
            IList<vDoors> x = qry.List<vDoors>();



Here is my mapping file (set as embedded resource):
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false" assembly="Operations" namespace="Tko.SmartMoves.Modules.Operations.Domain" default-lazy="false">
  <class name ="vDoors" table="dbo.vDoors" dynamic-update="false" lazy="false">
    <cache usage="read-only"/>
    <id name="DoorId" column="DoorId" type="Int64">
      <generator class="native" />
    </id>
    <property name="ParentZoneRecid" />
    <property name="ParentZone" />
    <property name="ParentZoneEnabled" />
    <property name="Zone" />
    <property name="ZoneStatus" />
    <property name="ZoneEnabled" />
    <property name="GenericRecid" />
    <property name="GenericEntity" />
    <property name="GenericName" />
    <property name="GenericEnabled" />
    <property name="GenericType" />
  </class>
</hibernate-mapping>



This is my class:
namespace Tko.SmartMoves.Modules.Operations.Domain
{

    // either way same "not mapped" errro public class vDoors : DomainObject<long>
    public class vDoors 
    {
        public virtual Int64 ParentZoneRecid { get; set; }
        public virtual string ParentZone { get; set; }
        public virtual bool ParentZoneEnabled { get; set; }
        public virtual Int64 DoorId { get; set; }
        public virtual string Zone { get; set; }
        public virtual string ZoneStatus { get; set; }
        public virtual bool ZoneEnabled { get; set; }
        public virtual Int64 GenericRecid { get; set; }
        public virtual string GenericEntity { get; set; }
        public virtual string GenericName { get; set; }
        public virtual bool GenericEnabled { get; set; }
        public virtual string GenericType { get; set; }

        public override int GetHashCode()
        {
            return (GetType().FullName + "|" + DoorId.ToString()).GetHashCode();
        }
    }

Gunnar Liljas

unread,
Sep 1, 2016, 12:06:22 PM9/1/16
to nhu...@googlegroups.com
You need to add the mappings too.

cfg.AddAssembly(....)

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

Steve Lyle

unread,
Sep 1, 2016, 12:49:56 PM9/1/16
to nhusers
I don't think I showed it in my original post but didn't I do that with the following from hibernate.cfg.xml?
Also other queries in this namespace are working without issue.

But I will still try what you say.

from hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
....
    <mapping assembly="Operations" />
....
  </session-factory>
</hibernate-configuration>
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.

Steve Lyle

unread,
Sep 1, 2016, 1:00:16 PM9/1/16
to nhusers
When I added the assembly programmatically cfg.AddAssembly("Operations");  This line of code throws the following.
I take this to mean hibernate.cfg.xml was already including the assembly.


----
Does it help to know that vRSMgrsScreenGrig & vDoors are both in the same name space?
- RSMgrs has a Dao and a IDoa interface.
- But I hadn't built a separate Doa and interface for vDoors.
Could this be a problem?
----




Server Error in '/' Application.

Duplicate class/entity mapping Tko.SmartMoves.Modules.Operations.Domain.vRSMgrsScreenGrid

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: NHibernate.DuplicateMappingException: Duplicate class/entity mapping Tko.SmartMoves.Modules.Operations.Domain.vRSMgrsScreenGrid

Source Error: 

Line 71: 
Line 72:             /* does NOT work (using HQL) ~ throws a "vDoors not mapped" error */
Line 73:             cfg.AddAssembly("Operations");
Line 74:             var ses = sesFactory.OpenSession();
Line 75:             // FAILS 

Steve Lyle

unread,
Sep 1, 2016, 1:39:00 PM9/1/16
to nhusers
Still the same error even after breaking vDoors out into its own Dao & Interface.

Steve Lyle

unread,
Sep 1, 2016, 1:58:13 PM9/1/16
to nhusers
Because my class.hbm.xml file has auto-import="false" I have to include the resolution/path in the query to the class object.

So both of the following queries work ... except full resolution should be .Domain.  instead of the typo .Data.
            //var qry = ses.CreateQuery("select ParentZoneRecid, ParentZone, ParentZoneEnabled, Zone, ZoneStatus, ZoneEnabled, GenericRecid, GenericEntity, GenericName, GenericEnabled, GenericType from Tko.SmartMoves.Modules.Operations.Domain.vDoors");
Not  //var qry = ses.CreateQuery("select ParentZoneRecid, ParentZone, ParentZoneEnabled, Zone, ZoneStatus, ZoneEnabled, GenericRecid, GenericEntity, GenericName, GenericEnabled, GenericType from Tko.SmartMoves.Modules.Operations.Data.vDoors");
            //var qry = ses.CreateQuery("select r from Tko.SmartMoves.Modules.Operations.Domain.vDoors r");  
Not  //var qry = ses.CreateQuery("select r from Tko.SmartMoves.Modules.Operations.Data.vDoors r");

Thanks.
I do have a follow on question.  I'll ask this in a different thread.
Reply all
Reply to author
Forward
0 new messages