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.  [ 6 posts ] 
Author Message
 Post subject: Error: urn:nhibernate-mapping-2.0 has incomplete content
PostPosted: Wed Aug 30, 2006 3:06 am 
Beginner
Beginner

Joined: Wed Aug 30, 2006 2:06 am
Posts: 24
Hi,

I am new to nhibernate. I am using VisualStudio 2003 and I have downloaded the nhibernate v1.2.0 alpha. I am trying to map a simple customer entity to customer table using console application and i am getting the following error.

The element 'urn:nhibernate-mapping-2.0:id' has incomplete content. Expected 'urn:nhibernate-mapping-2.0:column urn:nhibernate-mapping-2.0:generator'. An error occurred at file:///C:/Vijay/tryOr/Customer/Cust.hbm.xml, (9, 11).

My cust.hbm.xml is as follows.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="Customer" assembly="Customer">

<class name="cust" table="Cust">

<id name="Id">
<column name="Id" sql-type="16" not-null="true"/>
</id>
<property name="Name">
<column name="Name" length="16" not-null="true" />
</property>
<property name="City" />
<property name="Country" />
</class>

</hibernate-mapping>

Can anybody help me on this.

Thanks


Top
 Profile  
 
 Post subject: Re: Error: urn:nhibernate-mapping-2.0 has incomplete content
PostPosted: Wed Aug 30, 2006 3:10 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
vijayjanakiram wrote:
<id name="Id">
<column name="Id" sql-type="16" not-null="true"/>
</id>



The <id> tag needs "generator" attribute, like

<id name="Id" generator="assigned">
<column name="Id" sql-type="16" not-null="true"/>
</id>

if You want to assign ID-s by yourself

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: Re: Error: urn:nhibernate-mapping-2.0 has incomplete content
PostPosted: Wed Aug 30, 2006 3:43 am 
Beginner
Beginner

Joined: Wed Aug 30, 2006 2:06 am
Posts: 24
Thanks gert for the quick response...

1) I changed the config file and i am getting the following error.

<id name="Id" generator="assigned">
<column name="Id" sql-type="16" not-null="true"/>
</id>

Additional information: The 'generator' attribute is not declared. An error occurred at file:///C:/Vijay/tryOr/Customer/Cust.hbm.xml, (14, 23).

2) I changed the config file as given in the sample documentation
like this.

<id name="Id">
<column name="Id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex" />
</id>

I am getting the below error.

An unhandled exception of type 'NHibernate.InvalidProxyTypeException' occurred in nhibernate.dll

Additional information: method get_Id should be virtual

Cheers


Top
 Profile  
 
 Post subject: Re: Error: urn:nhibernate-mapping-2.0 has incomplete content
PostPosted: Wed Aug 30, 2006 4:25 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
vijayjanakiram wrote:
Thanks gert for the quick response...

1) I changed the config file and i am getting the following error.

<id name="Id" generator="assigned">
<column name="Id" sql-type="16" not-null="true"/>
</id>

Additional information: The 'generator' attribute is not declared. An error occurred at file:///C:/Vijay/tryOr/Customer/Cust.hbm.xml, (14, 23).

Next time I must check the documentation and not write from memory :(

vijayjanakiram wrote:
2) I changed the config file as given in the sample documentation
like this.

<id name="Id">
<column name="Id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex" />
</id>

I am getting the below error.

An unhandled exception of type 'NHibernate.InvalidProxyTypeException' occurred in nhibernate.dll

Additional information: method get_Id should be virtual


You must either make all public methods/proeprties virtual or add lazy="false" to class mapping.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: Re: Error: urn:nhibernate-mapping-2.0 has incomplete content
PostPosted: Wed Aug 30, 2006 5:10 am 
Beginner
Beginner

Joined: Wed Aug 30, 2006 2:06 am
Posts: 24
Awesome!!!! Appreciated.... It works!!!!
Can you let me know if i want to generated my own key for the primary field column, how should i change the config?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 5:42 am 
Newbie

Joined: Wed Aug 16, 2006 2:49 am
Posts: 14
Well having the generator class as assigned should make you able to do so. But you already specified "assigned" :)

<id name="Id">
<column name="Id" sql-type="16" not-null="true"/>
<generator class="assigned" />
</id>


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