-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: NHibernate.MappingException: No persisters for:
PostPosted: Tue Jul 26, 2005 11:12 am 
Newbie

Joined: Tue Jul 26, 2005 10:58 am
Posts: 5
Location: London
Hi

I'm a newbie to NHibernate so apologise in advance if this problem is due to my ignorance.

I get
Quote:
NHibernate.MappingException: No persisters for: MIPSDataEntry.User
when tring to save my object.

I am using a MySql Database and have remembered to rebuild the solution everytime I change the User.hbm.xml file which is an Embedded Resource.

It might be my sql to build the database???
Code:
CREATE TABLE users (
    id                  INT(32) NOT NULL AUTO_INCREMENT,
   logonID            VARCHAR(20) NOT NULL DEFAULT '0',
   name            VARCHAR(40) DEFAULT NULL,
   emailAddress      VARCHAR(40) DEFAULT NULL,
   lastLogon         DATETIME DEFAULT NULL,
   PRIMARY KEY  (id)
)   
TYPE=InnoDB
;


the User.hbm.xml file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="MIPSDataEntry.User, MIPSDataEntry" table="users">
      <id name="Id" column="id" type="Int32">
         <generator class="identity" />
      </id>
      <property name="LogonId" column= "logonId" type="String" length="20"/> 
      <property name="Name" column= "name" type="String" length="40"/>
      <property name="EmailAddress" column= "emailAddress" type="String" length="40"/>
      <property name="LastLogon" column= "lastLogon" type="DateTime"/>
   </class>

</hibernate-mapping>


the User class:
Code:
using System;

namespace MIPSDataEntry
{
   
   public class User
   {
      private Int32 id;
      private String logonID;


      private String name;
      private String emailAddress;
      private DateTime lastLogon;
      
      public User()
      {
         //
         // TODO: Add constructor logic here
         //
      }
      public Int32 Id
      {
         get { return id; }
         set { id = value; }
      }

      public string LogonId
      {
         get { return logonID; }
         set { logonID = value; }
      }

      public string Name
      {
         get { return name; }
         set { name = value; }
      }

      public string EmailAddress
      {
         get { return emailAddress; }
         set { emailAddress = value; }
      }

      public DateTime LastLogon
      {
         get { return lastLogon; }
         set { lastLogon = value; }
      }

   }
}


Once again, sorry if I'm being silly and Thanks in advance

_________________
Kent W Perry


Top
 Profile  
 
 Post subject: Re: NHibernate.MappingException: No persisters for:
PostPosted: Tue Jul 26, 2005 1:37 pm 
A small typo. Not sure its the whole solution.

In the hbm file logonId maps logonId but the column name is logonID in the tbl.



Quote:
CREATE TABLE users (
id INT(32) NOT NULL AUTO_INCREMENT,
logonID VARCHAR(20) NOT NULL DEFAULT '0',
name VARCHAR(40) DEFAULT NULL,
emailAddress VARCHAR(40) DEFAULT NULL,
lastLogon DATETIME DEFAULT NULL,
PRIMARY KEY (id)
)
TYPE=InnoDB
;

the User.hbm.xml file:
[code]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MIPSDataEntry.User, MIPSDataEntry" table="users">
<id name="Id" column="id" type="Int32">
<generator class="identity" />
</id>
<property name="LogonId" column= "logonId" type="String" length="20"/>
<property name="Name" column= "name" type="String" length="40"/>
<property name="EmailAddress" column= "emailAddress" type="String" length="40"/>
<property name="LastLogon" column= "lastLogon" type="DateTime"/>
</class>

</hibernate-mapping>


Top
  
 
 Post subject: Case doesn't matter
PostPosted: Wed Jul 27, 2005 5:33 am 
Newbie

Joined: Tue Jul 26, 2005 10:58 am
Posts: 5
Location: London
Thanks for the eagle eyes but unfortunately that isn't the problem :(

_________________
Kent W Perry


Top
 Profile  
 
 Post subject: Could it be my web.config?
PostPosted: Wed Jul 27, 2005 5:55 am 
Newbie

Joined: Tue Jul 26, 2005 10:58 am
Posts: 5
Location: London
Could it be the fact that I'm not using CharSet=win1250 or is it because my assembly is named wrong. I'm running out of ideas. Here's the first bit of my web.config file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   
  <configSections>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
   
  <nhibernate>
    <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect" />
    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver" />
    <add key="hibernate.connection.connection_string" value="Server=merbuildserv;Database=MIPSData;User ID=mips;Password=***" />
  </nhibernate>
  <system.web>

_________________
Kent W Perry


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 6:04 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This kind of errors is often caused by typos, or forgetting to mark the .hbm.xml as Embedded Resource in Visual Studio. Your mapping looks right at a glance, so maybe the problem is in the class names? Is your assembly really called MIPSDataEntry?


Top
 Profile  
 
 Post subject: Assembly Name
PostPosted: Wed Jul 27, 2005 6:21 am 
Yes it is.


Top
  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 10:41 am 
Beginner
Beginner

Joined: Tue Jul 19, 2005 11:21 am
Posts: 23
Location: erie, pa
I'm thinking that maybe your mapping file hasn't been loaded into your config objection. If there was a mismatch between your mapping file and the class it maps to, your app would raise an exception as soon as you do

config.AddAssembly(this.GetType().Assembly);

It looks like the session factory has a method called GetAllClassMetadata() that will give you a collection of all the classes that are loaded into it. You could loop through these to see if your class is actually in there.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 3:18 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Set log4net to DEBUG and read the file log.txt to be sure that your hbm.xml files are correctly loaded...

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 6:32 am 
Newbie

Joined: Tue Jul 26, 2005 10:58 am
Posts: 5
Location: London
I don't get an error when I run
Quote:
config.AddAssembly(this.GetType().Assembly);
but my class isn't listed in the collection of mapped files loaded into the session factory.

My nhibernate.txt file from the logs has the following
Code:
11:23:07.300 [1872] INFO  NHibernate.Cfg.Configuration - processing one-to-many association mappings
11:23:07.315 [1872] INFO  NHibernate.Cfg.Configuration - processing one-to-one association property references
11:23:07.315 [1872] INFO  NHibernate.Cfg.Configuration - processing foreign key constraints
11:23:07.315 [1872] INFO  NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MySQLDialect
11:23:07.315 [1872] INFO  NHibernate.Cfg.SettingsFactory - use outer join fetching: True
11:23:07.315 [1872] INFO  NHibernate.Connection.ConnectionProviderFactory - Intitializing connection provider: NHibernate.Connection.DriverConnectionProvider
11:23:07.315 [1872] INFO  NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
11:23:07.362 [1872] INFO  NHibernate.Cfg.SettingsFactory - Query language substitutions:
11:23:07.362 [1872] INFO  NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.HashtableCacheProvider
11:23:07.362 [1872] INFO  NHibernate.Cfg.Configuration - instantiating and configuring caches
11:23:07.362 [1872] INFO  NHibernate.Impl.SessionFactoryImpl - building session factory
11:23:07.362 [1872] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: hibernate.dialect=NHibernate.Dialect.MySQLDialect;hibernate.connection.connection_string=***;hibernate.connection.provider=NHibernate.Connection.DriverConnectionProvider;hibernate.connection.driver_class=NHibernate.Driver.MySqlDataDriver;
11:23:07.362 [1872] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
11:23:07.362 [1872] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - registered: 0c8ad03e4ee5496e92ff899476a53a2f(unnamed)
11:23:07.362 [1872] INFO  NHibernate.Impl.SessionFactoryObjectFactory - no name configured
11:23:07.362 [1872] DEBUG NHibernate.Impl.SessionFactoryImpl - Instantiated session factory
11:23:10.221 [1872] DEBUG NHibernate.Impl.SessionImpl - opened session
11:23:10.221 [1872] DEBUG NHibernate.Transaction.AdoTransaction - begin
11:23:10.221 [1872] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver


Anyone got anymore ideas :idea:

_________________
Kent W Perry


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 9:19 am 
Beginner
Beginner

Joined: Thu May 12, 2005 2:14 am
Posts: 33
Location: Sweden, Sk
Hi

Are you sure the hbm.xml file is marked as a Embedded Resource and check so that you are adding the right assembly.

If you dont solve it by checking thoose things. Feel free to send the project to me, pm me to get my email adress. And I will see if I can help you with it.

/patrik


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 9:34 am 
Newbie

Joined: Tue Jul 26, 2005 10:58 am
Posts: 5
Location: London
Thank you to everyone that has tried to help me this week, I feel like a bit of a fool though. I struggle a bit to read my monitor and a collegue has just pointed out to me that my hibernate mapping files have the extension .hbn.xml and not .hbm.xml. All is working now, so thanks again

_________________
Kent W Perry


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 11:02 am 
Newbie

Joined: Fri Jun 30, 2006 11:00 am
Posts: 1
KePe wrote:
Thank you to everyone that has tried to help me this week, I feel like a bit of a fool though. I struggle a bit to read my monitor and a collegue has just pointed out to me that my hibernate mapping files have the extension .hbn.xml and not .hbm.xml. All is working now, so thanks again


Why god dam! Ive just done the same thing!!

Stephen.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.