-->
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.  [ 4 posts ] 
Author Message
 Post subject: SetDefaultAssembly and SetDefaultNamepsace not working?
PostPosted: Mon Apr 16, 2007 5:22 pm 
Newbie

Joined: Mon Apr 16, 2007 5:07 pm
Posts: 3
After updating to 1.2.0RC2 from 1.2.0RC1 it appears that SetDefaultAssembly and SetDefaultNamespace have stopped working. Can someone confirm?

Code:
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration()
cfg.SetDefaultAssembly("A.B");
cfg.SetDefaultNamespace("A.B");


using these parameters when I load the A.B assembly

Code:
cfg.AddAssembly("A.B");


I get the following error when NHibernate tries to load the mappings from the assembly.

"These classes extend unmapped classes
ResidenceAddress extends A.B.DomainModel.Address, A.B"

A.B.DomianModel.Address is mapped as "Address" with the namespace removed so I can use the default namespace. ResidenceAddress also is in the namespace A.B, but the namespace is removed in the mapping file.

The code base remains unchanged, the only difference is the NHibernate dlls.

I am missing something?


Top
 Profile  
 
 Post subject: Work Around
PostPosted: Mon Apr 16, 2007 6:16 pm 
Newbie

Joined: Mon Apr 16, 2007 5:07 pm
Posts: 3
I found a work around that works. Instead of setting the global default namespace and assemblies like before, I can set it on a HBM by HBM file basis.

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="A.B" namespace="A.B.DomainModel">


While not the solution I'm looking for, it is viable for now.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 2:26 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I don't understand what the problem is... can you post the mappings here and also tell us how you expect it to work?

The problem is not in SetDefaultAssembly/SetDefaultNamespace, but in changes made to the way extends attribute is handled.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 11:40 am 
Newbie

Joined: Mon Apr 16, 2007 5:07 pm
Posts: 3
sergey wrote:
I don't understand what the problem is... can you post the mappings here and also tell us how you expect it to work?

The problem is not in SetDefaultAssembly/SetDefaultNamespace, but in changes made to the way extends attribute is handled.


Thanks Sergey. It appears you are correct, the problem seems to be in the extends statement.

In both RC1 and RC2 I set the default namespace to A.B and assembly to A.B as well.

Here is the base class. Notice how the namespace and assembly are not included in the class name.
Code:
   <class name="Address" table="Address" lazy="false">

This class does the extending. Note how the extends statement lists the base class by its fully qualified name and assembly.
Code:
   <joined-subclass name="ResidenceAddress" extends="A.B.Address, A.B" table="ResidenceAddress" .../>

This works fine in RC1.

Here is what I had to do to get it to work in RC2.
My base class remains the same with the namespace and assembly removed.
Code:
<class name="Address" table="Address" lazy="false">

I needed to remove the fully qualified name in the extends statement. Otherwise I get the class not mapped error.
Code:
<joined-subclass name="ResidenceAddress" extends="Address" table="ResidenceAddress" .../>


I've fixed my inconsistencies but I think I think the system should be able could find the mapped class despite the inconsistencies.


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