-->
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.  [ 2 posts ] 
Author Message
 Post subject: WinApp: Unknown Entity error; NOT an embedded resource issue
PostPosted: Thu Nov 09, 2006 6:53 pm 
Newbie

Joined: Thu Nov 09, 2006 6:15 pm
Posts: 1
I am getting the common "unknown entity:" error when saving, but to start it off, all of my hbm.xml files are set to embedded resource.

I've narrowed the problem down to an entityset that is contained within a component, which is in turn contained in a larger class. ie

<class>
<property>
<property>
<component>
<property>
<set>
</component>
</class>

When I go to save, everything works IF the <set> contained within the <component> is empty. If the <set> has anything in it, I get an unknown entity error on the class associated with the component. It's got to have something to do with the <set> as I don't get the error if the <set> is empty, and the other regular <property> values within <component> are stored in the db just fine.

Ok, so details:

Log File:
I think the issue shows up in the log file here:
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class CBPDataEntry.Domain.MaritalStatus
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\Documents and Settings\nick.kirkes\My Documents\Visual Studio 2005\Projects\CBPDataEntry\CBPDataEntry\bin\Debug\NHibernate.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\Documents and Settings\nick.kirkes\My Documents\Visual Studio 2005\Projects\CBPDataEntry\CBPDataEntry\bin\Debug\CBPDataEntry.exe
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\Documents and Settings\nick.kirkes\My Documents\Visual Studio 2005\Projects\CBPDataEntry\CBPDataEntry\bin\Debug\NHibernate.Generics.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll
2006-11-09 15:30:44,199 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\Documents and Settings\nick.kirkes\My Documents\Visual Studio 2005\Projects\CBPDataEntry\CBPDataEntry\bin\Debug\log4net.dll
2006-11-09 15:30:44,214 [1148] INFO NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Disabling reflection optimizer for class CBPDataEntry.Domain.MaritalStatus
2006-11-09 15:30:44,214 [1148] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - CodeDOM compilation failed
System.NullReferenceException: Object reference not set to an instance of an object.
at NHibernate.Persister.GetSetHelperFactory.GenerateCode()
at NHibernate.Persister.GetSetHelperFactory.CreateGetSetHelper()

The Unknown error comes back on CBPDataEntry.Domain.MaritalStatus. Keep in mind that when I view the object just before it's sent to the db, the object is NOT null, it's fine. And this only happens when that <set> collection has something in it.

Here is the mapping for the <component>:

<component name="MaritalStatus" class="CBPDataEntry.Domain.MaritalStatus, CBPDataEntry">
<property name="CurrentMaritalStatus" column="MaritalStatus" />
<property name="SpouseName" column="SpouseName" />
<property name="SpouseBirthDate" column="SpouseBirthDate" />
<property name="SpouseBirthPlace" column="SpouseBirthPlace" />
<property name="SpouseSSN" column="SpouseSSN" />
<set
lazy="false"
inverse="true"
name="SpouseOtherNames"
access="NHibernate.Generics.GenericAccessor+PascalCaseMUnderscore, NHibernate.Generics"
table="SpouseOtherNames"
cascade="all-delete-orphan">
<key column="SubjectId" />
<one-to-many class="CBPDataEntry.Domain.SpouseOtherName, CBPDataEntry" />
</set>
<property name="SpouseCitizenCountry" column="SpouseCitizenCountry" />
<property name="MarriageDate" column="MarriageDate" />
<property name="MarriagePlace" column="MarriagePlace" />
<property name="MarriageState" column="MarriageState" />
<property name="SeperationDate" column="SeperateDate" />
<property name="SeperationRecordLocation" column="SeperateRecordLocation" />
<property name="SeperationState" column="SeperateRecordState" />
<property name="SpouseAddress" column="SpouseAddress" />
<property name="SpouseState" column="SpouseState" />
<property name="SpouseZipCode" column="SpouseZipCode" />
</component>

and here is the mapping for the <set> (obviously contained in it's own hbm):

<class name="CBPDataEntry.Domain.SpouseOtherName, CBPDataEntry" table="SpouseOtherNames">
<id name="OtherNameId" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="LastName" column="LastName" />
<property name="FirstName" column="FirstName" />
<property name="MiddleName" column="MiddleName" />
<property name="Suffix" column="Suffix" />
<property name="FromDate" column="FromDate" />
<property name="ToDate" column="ToDate" />
<many-to-one
name="ParentObject"
column="SubjectId"
access="NHibernate.Generics.GenericAccessor+PascalCaseMUnderscore, NHibernate.Generics"
class="CBPDataEntry.Domain.SpouseOtherName, CBPDataEntry" />
</class>

The code that saves this mess:

session = Program.NHSession;
transaction = session.BeginTransaction();
session.SaveOrUpdate(section);
transaction.Commit();
... where section is a class that contains public properties along with a component MaritalStatus property.

When I break on the above code, on the SaveOrUpdate call, I can see that all the appropriate objects are NOT null. They have the correct data in them.

Any help would be appreciated.


Top
 Profile  
 
 Post subject: Unknown entity class error.
PostPosted: Fri Feb 02, 2007 12:29 pm 
Newbie

Joined: Thu Feb 01, 2007 4:47 pm
Posts: 1
Hi Jetson,

I don't know if this will help, but I was having a similar problem and everywhere I looked, the only solution was set file to 'Embedded', even though I had already done that. The problem was completely boneheaded on my part, hopefully it's the same with you. :-)

I've just been playing around with NHibernate for the past couple of days using VB.NET and a Windows App.

I've was working off of the NHibernate Quick Start Guide and in trying to get it working, was cutting and pasting things all over the place. Eventually I ended up with...

Code:
cfg.AddAssembly("...")


...in the wrong place. Rather than having it right after declaring the Configuration object, I had it after...

Code:
factory.OpenSession()


I moved it back to where it should be, and after that, things worked fine.

Cheers,
Chris


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