-->
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: Error: 'No persisters for: MyApp.Core.Domain.Employee
PostPosted: Wed May 18, 2005 9:12 am 
I get an error when I call

Code:
public IList GetAll(Type type)
{
  ICriteria crit = this._activeSession.CreateCriteria(type);
  return crit.List();
}


The error is: "No persisters for: MyApp.Core.Domain.Employee."

I made a class Employee in the namespace MyApp.Core.Domain.
I also made a Employee.hbm.xml. NHibernate doesn't seem to find a mapping of the Employee-class.

Is there something I missed?


Top
  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This is usually caused by an xml file not being set to "embedded resource", or a typo in the mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 10:47 am 
Sergey,

You were right, I set the xml to Embedded Resource, now that error is solved. But now, I get another error which has to do with the content of the hbm.xml. Does it ring a bell with someone?

Server Error in '/LeagueManager' Application.
--------------------------------------------------------------------------------

This is an unexpected token. The expected token is 'NAME'. Line 5, position 3.
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.

Code:
Exception Details: System.Xml.XmlException: This is an unexpected token. The expected token is 'NAME'. Line 5, position 3.

Source Error:


Line 91:       {
Line 92:          Configuration config = new Configuration();
Line 93:          this._nhibernateConfiguration = config.AddAssembly(this.GetType().Assembly);
Line 94:          this._nhibernateFactory = this._nhibernateConfiguration.BuildSessionFactory();
Line 95:       }


Top
  
 
 Post subject:
PostPosted: Wed May 18, 2005 10:54 am 
Beginner
Beginner

Joined: Thu May 12, 2005 3:41 am
Posts: 24
Location: London, UK
This is a syntax error in your hbm.xml file. If you post the file, I'll see if I can spot the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 12:00 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 2:48 pm
Posts: 47
I have 4 hbm.xml files so far. I posted the content of the xml files, but isn't there a possibility to attach files as on other forums?

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="LeagueManager.Core.Domain.Season, LeagueManager.Core" table="season"
   
      <id name="Id" column="seasonid" type="Int32" unsaved-value="-1">
         <generator class="native">
            <param name="sequence">season_seasonid_seq</param>
         </generator>
      </id>
      
      <property name="Description" column="description" type="String" length="100" />
      
      <bag name="Leagues" cascade="all" lazy="true">
         <key column="seasonid" />
         <one-to-many class="LeagueManager.Core.Domain.League, LeagueManager.Core" />
      </bag>
   </class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="LeagueManager.Core.Domain.League, LeagueManager.Core" table="league"
      proxy="LeagueManager.Core.Domain.League, LeagueManager.Core">
      
      <id name="Id" column="leagueid" type="Int32" unsaved-value="-1">
         <generator class="native">
            <param name="sequence">league_leagueid_seq</param>
         </generator>
      </id>
      
      <property name="Description" column="description" type="String" length="100" />

   </class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="LeagueManager.Core.Domain.LeagueDefinition, LeagueManager.Core" table="leaguedefinition"
      proxy="LeagueManager.Core.Domain.LeagueDefinition, LeagueManager.Core">
      
      <id name="Id" column="leaguedefinitionid" type="Int32" unsaved-value="-1">
         <generator class="native">
            <param name="sequence">leaguedefinition_leaguedefinitionid_seq</param>
         </generator>
      </id>
      
      <property name="Name" column="name" type="String" length="100" />
      <property name="AmountOfTeams" column="amountofteams" type="Int32"/>      
      
      <one-to-one name="Points" class="Points"/>

   </class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="LeagueManager.Core.Domain.Points, LeagueManager.Core" table="points"
      proxy="LeagueManager.Core.Domain.Points, LeagueManager.Core">
      
      <id name="Id" column="leagueid" type="Int32" unsaved-value="-1">
         </generator class="foreign">
            <param name="property">League</param>
         </generator>
      </id>
      
      <property name="Win" column="win" type="Int32" />
      <property name="Draw" column="draw" type="Int32" />
      <property name="Loss" column="loss" type="Int32" />
      
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 12:28 pm 
Beginner
Beginner

Joined: Thu May 12, 2005 3:41 am
Posts: 24
Location: London, UK
Hi

The last file for the Points class has a typing error - the opening tag for the <generator> element has got an extra '/'. i.e.
Code:
</generator class="foreign">
should read
Code:
<generator class="foreign">


I don't think that there is any way of attaching files to a post - unless someone else knows otherwise?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 2:07 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 2:48 pm
Posts: 47
Bill,

I fixed the generator-part, but I keep getting the same error.
There must be something wrong with my hbm.xml files.

Does anyone have a working demo perhaps, so I can validate my way of working with NHibernate?

Is it also possible to debug NHibernate classes while debugging my project?


Last edited by JackBigMac on Wed May 18, 2005 2:33 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 2:18 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You have to rebuild the project, because Visual Studio doesn't notice a change in embedded content .xmls and doesn't replace them. See the FAQ: http://wiki.nhibernate.org/display/NH/Frequently%20Asked%20Questions


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 2:39 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 2:48 pm
Posts: 47
Sergey,

I already took that in consideration. I rebuilded the solution, but no effect. The same error remains.: Exception Details: System.Xml.XmlException: This is an unexpected token. The expected token is 'NAME'. Line 5, position 3.

Which name is meant? line 5 of which file? Is it all the info I can get about the location?

A season can have multiple leagues. Is it the one-to-many relationship ok like I defined it?


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

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The 'NAME' is apparently the name of a token (element name, perhaps) that the XML parser expects to find but doesn't. As to which file, it's of course an oversight that the message does not include the file name, but you may be able to find it in a log if you configure logging.

I don't think there's anything wrong with the way you're using NHibernate, it's just a typo in one of the mapping files. Do you have any spaces between < and the element name somewhere?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:58 pm 
Beginner
Beginner

Joined: Tue May 17, 2005 2:48 pm
Posts: 47
Indeed, it was a typo. As you can see in my earlier post, I forgot '>' on the <class>-element in the first two mapping files.
Thanx anyway for your help.


Top
 Profile  
 
 Post subject: Re: Error: 'No persisters for: MyApp.Core.Domain.Employee
PostPosted: Mon Nov 14, 2011 4:04 am 
Newbie

Joined: Wed Sep 21, 2011 9:34 am
Posts: 6
Nice that the mistake was found)) many thanks for the help))


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.