-->
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.  [ 6 posts ] 
Author Message
 Post subject: Help: persistent class not found
PostPosted: Mon Jan 02, 2006 7:25 am 
Newbie

Joined: Sat Dec 31, 2005 3:03 pm
Posts: 4
Hi everybody,

I am new to nhibernate and I cannot get past a MappingException and 'persistent class <class name> not found'. I read all the relevant posts but could not solve this problem. I created a db and generated the mapping files with MyGeneration tool. I included them as embedded resources but cannot make it work. The project is called 'libitum', the namespace of objects is 'objs'. The object mapping file is the following:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="objs.ingredient, libitum" table="ingredient">
<id name="id" column="id" type="String" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="category" column="category" type="String" />
<property name="description" column="description" type="String" />
<property name="season" column="season" type="String" />
<property name="unit" column="unit" type="String" not-null="true" />
<property name="quantity" column="quantity" type="Double" not-null="true" />
<property name="currency" column="currency" type="String" not-null="true" />
<property name="price" column="price" type="Decimal" not-null="true" />
</class>
</hibernate-mapping>

I have activated the debugging to console and here is what I get:

2006-01-02 12:23:12,187 [13520] ERROR NHibernate.Cfg.Configuration [(null)] &lt;(null)&gt; - Could not compile the mapping document
NHibernate.MappingException: persistent class objs.ingredient not found ---> System.TypeLoadException: Impossibile caricare il tipo objs.ingredient dall'assembly NHibernate, Version=1.0.1.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc.
at System.Type.GetType(String typeName, Boolean throwOnError)
at NHibernate.Util.ReflectHelper.ClassForName(String name)
at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
--- Fine dell'analisi dello stack dell'eccezione interna ---
at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
at NHibernate.Cfg.Binder.BindClass(XmlNode node, PersistentClass model, Mappings mapping)
at NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
at NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model)
at NHibernEccezione non gestita di tipo "NHibernate.MappingException" in nhibernate.dll

Informazioni aggiuntive: persistent class objs.ingredient not found

ate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc)
"Libitum.exe": caricato "c:\windows\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll", nessun simbolo caricato.


I cannot figure out what is wrong... any help reeeeeeeeally welcome !!!!

Luca


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 7:58 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
Could you please post your Class?
Is the namespace and the assemnlie in
Code:
<class name="objs.ingredient, libitum" table="ingredient">

correct?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 8:43 am 
Newbie

Joined: Sat Dec 31, 2005 3:03 pm
Posts: 4
Hi there!

here is the class....

I can correctly reference libitum.objs.ingredient or objs.ingredient ...
the error lies when I issue this code:

Dim NHCfg As New NHibernate.Cfg.Configuration
Dim i As New Libitum.objs.ingredient

Dim x As log4net.Config.XmlConfigurator
x.Configure()


NHCfg.AddAssembly("Libitum")

Dim nhSF As NHibernate.ISessionFactory = NHCfg.BuildSessionFactory
Dim nhS As NHibernate.ISession = nhSF.OpenSession()


imports System
Imports System.Collections
Imports NHibernate

Namespace objs

#Region "Class ingredient"
''' <summary>
'''
''' </summary>
<Serializable()> Public Class ingredient

#Region "Private Members"
Private _IsChanged As Boolean
Private _isDeleted As Boolean
Private _id As String
Private _category As String
Private _description As String
Private _season As String
Private _unit As String
Private _quantity As Double
Private _currency As String
Private _price As Decimal
#End Region ' End of Private Members

#Region "Public Accessors"
''' <summary>
'''
''' </summary>
Public Property id() As String
Get
Return _id
End Get
Set(ByVal Value As String)
If Value <> _id Then
_id = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property category() As String
Get
Return _category
End Get
Set(ByVal Value As String)
If Value <> _category Then
_category = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property description() As String
Get
Return _description
End Get
Set(ByVal Value As String)
If Value <> _description Then
_description = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property season() As String
Get
Return _season
End Get
Set(ByVal Value As String)
If Value <> _season Then
_season = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property unit() As String
Get
Return _unit
End Get
Set(ByVal Value As String)
If Value <> _unit Then
_unit = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property quantity() As Double
Get
Return _quantity
End Get
Set(ByVal Value As Double)
If Value <> _quantity Then
_quantity = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property currency() As String
Get
Return _currency
End Get
Set(ByVal Value As String)
If Value <> _currency Then
_currency = Value
_IsChanged = True
End If
End Set
End Property

''' <summary>
'''
''' </summary>
Public Property price() As Decimal
Get
Return _price
End Get
Set(ByVal Value As Decimal)
If Value <> _price Then
_price = Value
_IsChanged = True
End If
End Set
End Property


#Region "IsChanged"
''' <summary>
''' Returns whether or not the object has changed it's values.
''' </summary>
Public ReadOnly Property IsChanged() As Boolean
Get
Return _IsChanged
End Get
End Property
#End Region 'HasChanged

#Region "IsDeleted"
''' <summary>
''' Returns whether or not the object has changed it's values.
''' </summary>
Public ReadOnly Property IsDeleted() As Boolean
Get
Return _isDeleted
End Get
End Property
#End Region 'IsDeleted

#End Region 'Public Accessors



End Class
#End Region ' Class ingredient

End Namespace


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 8:45 am 
Newbie

Joined: Sat Dec 31, 2005 3:03 pm
Posts: 4
sorry I did not put a break where the class starts: obviously the class code starts with the 'imports' lines...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 1:43 pm 
Newbie

Joined: Sat Dec 31, 2005 3:03 pm
Posts: 4
solved !!!

strangely I added a hierarchy in the project and worked!

instead of 'libitum', I created 'app.libitum'...

thanx anyway


Top
 Profile  
 
 Post subject: Re: Help: persistent class not found
PostPosted: Wed Jan 04, 2006 4:00 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Just as a side note, this:

italiantaz wrote:
Code:
<id ... unsaved-value="0">
    <generator class="assigned" />
</id>


will not really do anything. If you need to use unsaved-value because you intend to use SaveOrUpdate(), try adding a version column and using its unsaved-value attribute. Either way, you should remove it from your assigned id.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.