-->
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.  [ 3 posts ] 
Author Message
 Post subject: NHMA Not Outputting Certain XML Tags
PostPosted: Thu Feb 22, 2007 3:51 pm 
Newbie

Joined: Tue Feb 06, 2007 12:48 pm
Posts: 2
NHibernate version: 1.2.0 Beta3
NHibernateContrib version: 1.0.4.0

I've been using NHibernate Mapping Attributes for a while now to decorate my business objects and have started implementing relationships between objects. I have a Checklist object which has a collection of ChecklistItem objects. So in my Checklist object, I have:

Code:
[Property(9)]
public int DatasetID {...}

[Set(Name = "NHChecklistItems", Inverse = true, Lazy = false)]
[Key(Column = "ChecklistID")]
[OneToMany(Class = "PAO.BLL.ChecklistItem, PAO")]
private Iesi.Collections.ISet NHChecklistItems {...}


Sometimes when I run my testcases, they fail with the following error:

Code:
NHibernate.MappingException: (166,7): XML validation error: The element 'set' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:element urn:nhibernate-mapping-2.2:one-to-many urn:nhibernate-mapping-2.2:many-to-many urn:nhibernate-mapping-2.2:composite-element urn:nhibernate-mapping-2.2:many-to-any'. ---> System.Xml.Schema.XmlSchemaValidationException: The element 'set' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:element urn:nhibernate-mapping-2.2:one-to-many urn:nhibernate-mapping-2.2:many-to-many urn:nhibernate-mapping-2.2:composite-element urn:nhibernate-mapping-2.2:many-to-any'.


Then I look at the XML hibernate mapping generated by NHMA and notice that the key and one-to-many tags are missing from the set tag. At first this all seemed to happen at random, but in playing around with it, I noticed that I'd have a higher success rate if I moved the Set, Key, and OneToMany attributes (and their corresponding .NET property) up so that they weren't the last mapping attributes in the class. In other words, The likelyhood of an error occurring would be a lot less if I changed the order of the mappings to:

Code:
[Set(Name = "NHChecklistItems", Inverse = true, Lazy = false)]
[Key(Column = "ChecklistID")]
[OneToMany(Class = "PAO.BLL.ChecklistItem, PAO")]
private Iesi.Collections.ISet NHChecklistItems {...}

[Property(9)]
public int DatasetID {...}


Does the order of NHMA tags in the .NET code matter? All of the NHibernate examples I've seen show that any object's collection mappings come after that object's property mappings, so I also put my set mappings after the property mappings.

Hopefully I'm explaining this well enough. Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 3:06 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Since .NET attributes do not maintain order, you need to specify one explicitly, using something like this (I don't know NHMA to detail):
Code:
[Set(0, ...)]
[Key(1, ...)]
[OneToMany(2, ...)]


Also, are you really using NHContrib 1.0.4 with NHibernate 1.2.0.Beta3? The Beta3 distribution includes compatible NHContrib libraries.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 10:10 am 
Newbie

Joined: Tue Feb 06, 2007 12:48 pm
Posts: 2
Ah thank you for your response. It had not occurred to me to specify order in the Key and OneToMany tags as well. So far it's working =)

I also didn't realize that NHContrib libraries were included in the Beta3. Duh, I should've checked. Isn't the 1.0.4 release newer than the NHContrib included with the Beta3?

Thanks again for your help.


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