Hi every body !

Im new in nhibernate world. I create my first example aplication and
create one simple domain :

namespace DataObjects.Domain
{
   public class User
   {
       public virtual long Usid { get; set; }
       public virtual string Name { get; set; }
       public virtual long Prid { get; set; }
       public virtual DateTime Crdt { get; set; }
   }
}

The Prid field is a Foreing Key to the same table Users

The DB definition for this is simple as well

 CREATE TABLE users (
 usid SERIAL PRIMARY KEY,
 name VARCHAR(50) NOT NULL,
 prid INTEGER NOT NULL REFERENCES users ON UPDATE CASCADE ON DELETE
CASCADE,
 crdt TIMESTAMP NOT NULL DEFAULT now()

ok. I first mapping this table in this way :

<class name="DataObjects.Domain.User, DataObjects" table ="users" >
   <id name="Usid" column="usid" type="long" unsaved-value="0">
     <generator class="native">
       <param name="sequense">users_usid_seq</param>
     </generator>
   </id>
   <timestamp name="Crdt" column="crdt" generated="always"></
timestamp>
   <property name="Name" column="name" type="String" length="50" not-
null="true"></property>
<property name="Prid" column="prid" type="long" not-null="true"></
property>
 </class>



A simple test to retrieve a user by id was succsefull an create this
SQL :

SELECT user0_.usid as usid1_0_, user0_.crdt as crdt1_0_, user0_.name
as name1_0_, user0_.prid as prid1_0_ FROM users user0_ WHERE
user0_.usid=:p0; :p0 = '0'



Then, i want map the table more exactly an create this mapping file
that include a many-to-one tag for express the forey key constrain:

 <class name="DataObjects.Domain.User, DataObjects" table ="users" >
   <id name="Usid" column="usid" type="long" unsaved-value="0">
     <generator class="native">
       <param name="sequense">users_usid_seq</param>
     </generator>
   </id>
   <timestamp name="Crdt" column="crdt" generated="always"></
timestamp>
   <property name="Name" column="name" type="String" length="50" not-
null="true"></property>
 <many-to-one name="Prid" column="usid"
class="DataObjects.Domain.User, DataObjects" cascade="all"></many-to-
one>
 </class>


But when i test this, Nhiernate generate this error:

NHibernate.MappingException: Invalid mapping information specified for
type DataObjects.Domain.User, check your mapping file for property
type mismatches

and the SQL generated, not include this field:


SELECT user0_.usid as usid1_0_, user0_.crdt as crdt1_0_, user0_.name
as name1_0_ FROM users user0_ WHERE user0_.usid=:p0; :p0 = '0'



?why this happen?

Can some one help my please?

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to