-->
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.  [ 8 posts ] 
Author Message
 Post subject: Enumeration Bug?
PostPosted: Sat Aug 20, 2005 1:51 pm 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Hi,

I've got a mapped class which has a property with an enumeration type which is marked as [Serializable]. The mapping is as follows:

Code:
<property name="jobType" column="JobType" type="Enums.DeliveryJobType" access="field" />


The problem is that an exception is thrown by the GetTypeFromXML method of the Cfg\Binder.cs class saying that the Enums.DeliveryJobType enumeration can't be interpreted:

Code:
could not interpret type: Enum.DeliveryJobType


I traced through the code and it appears that the HeuristicType method in Type\TypeFactory.cs is receiving null from ReflectHelper.ClassForName because that method is actually throwing the following exception:

Code:
System.SystemException   {"Could not load type Enums.DeliveryJobType from assembly NHibernate, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null."}   System.SystemException


This seems a little wierd. Should this method be looking in the NHibernate assembly rather than my assembly?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2005 2:25 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Quote:
Should this method be looking in the NHibernate assembly rather than my assembly?

You didn't qualify the type with the assembly name, so the appropriate function (Type.GetType) looks in the executing assembly, which happens to be NHibernate.dll. Just use type="Enums.DeliveryJobType, YourAssembly" and everything will be ok.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 21, 2005 6:10 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
You can also specify the namespace/assembly attributes for hibernate-mapping which will flip the default to your assembly from NHibernate's.

This was broken recently for types, but I think was fixed in the 0.9 release.

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 7:51 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Hmm.

I actually did have the namespace and assembly attributes set in the hibernate-mapping, however the namespace I'm using there is a sub-namespace of the one in which the enumeration exists.

I guess when you specifiy the FQN for an object and it's not in the same namespace as the one for the hibernate-mapping it must not use the assembly attribute for that property and requires the assembly as well.

I'll look into it an report back.

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 10:37 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
OK, I tried the change and while it the factory no longer throws an exception not all is well...

When I put together a query like so...

Code:
FROM DeliveryJob job WHERE job.jobType = My.Framework.Core.DeliveryJobType.Standard


I get the error:

Code:
NHibernate.ADOException: Could not execute query ---> System.Data.SqlClient.SqlException: The number name 'My.Framework.Core.DeliveryJobStatus' contains more than the maximum number of prefixes. The maximum is 3.


Obviously the naming convention here is an example only, however I do have to use nested namespaces of more than 3. Is there any way to get around this?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 6:04 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This looks like a bug in NHibernate. I'll bookmark this page and investigate it later.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 23, 2005 3:48 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Cheers Sergey!

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 11:15 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ok, I believe that to allow enum constants to be used, you have to <import> the type. I have an idea related to this problem which I'm going to add to JIRA now.


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