-->
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: NHibernate works for me if I map ONE class only!!!
PostPosted: Tue Apr 11, 2006 10:51 am 
Newbie

Joined: Tue Apr 11, 2006 10:36 am
Posts: 1
Has anyone encountered this problem, and do you have a solution?
Code:
Thanks.


I am using NHibernate.Mapping.Attributes to decorate my classes, then I open the config, yada yada yada, and I am able to issue a session.Load command successfully. HOWEVER, when I add another class with just one property (and id), I get an error:


Quote:
The element 'id' in namespace 'urn:nhibernate-mapping-2.0' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:column urn:nhibernate-mapping-2.0:generator'.


here is how I read the attributes:

Code:
            using (MemoryStream stream = new MemoryStream())
            {
                serializer.Serialize(stream, System.Reflection.Assembly.GetExecutingAssembly());
                stream.Position = 0;
                config.AddInputStream(stream);
            }

            factory = config.BuildSessionFactory();



Here is the content of stream:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2006-04-11 10:03:40Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="HomeSpace.Resource, NHibernateTest2" table="RESOURCE">
    <id column="ResourceId" type="System.Guid">
      <generator class="native" />
    </id>
    <property name="LoginID" column="NTLoginID" />
    <property name="EmployeeNo" column="EMPLOYEE" />
  </class>
  <class name="HomeSpace.EMPLOYER, NHibernateTest2" table="EMPLOYER">
    <id column="EMPLOYER_ID" type="Int32" />
  </class>
</hibernate-mapping>


I then noticed that the id of EMPLOYER_ID column does not have a
Code:
<generator>
, so I added it manullay by saving the content of the stream to an xml file, editing it, then using
Code:
config.AddXmlFile("c:\\config.xml");
instead of a memory stream. I get the same problem!!!


Top
 Profile  
 
 Post subject: Re: NHibernate works for me if I map ONE class only!!!
PostPosted: Tue Apr 11, 2006 11:06 am 
Regular
Regular

Joined: Fri Jan 27, 2006 2:32 pm
Posts: 102
Location: California, USA
Quote:
The element 'id' in namespace 'urn:nhibernate-mapping-2.0' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:column urn:nhibernate-mapping-2.0:generator'.


Incomplete content is the problem, as it states. The problem is not having 2 nh mappings.

Quote:
I then noticed that the id of EMPLOYER_ID column does not have a
Code:
<generator>
, so I added it manullay by saving the content of the stream to an xml file, editing it, then using
Code:
config.AddXmlFile("c:\\config.xml");
instead of a memory stream. I get the same problem!!!


Yes, this seems to be the problem. You say you "added it"... I think we need to see the contents of "config.xml" to see how you added it. It would seem you didn't add it correctly.

Post the contents of config.xml and let's see how to fix it.


Top
 Profile  
 
 Post subject: Attributes Order
PostPosted: Fri Apr 14, 2006 12:04 am 
Regular
Regular

Joined: Fri Jul 29, 2005 9:46 am
Posts: 101
Hi!
You could also post how are you using the attributes (to specify the order as the first parameter is very important to ensure good mapping generation)
bye


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.