Hi,
I am struggling with some nHibernate mapping. The project I am working
on uses a legacy database(thats why I have composite id's). I am
trying to map two entities, one with composite id, but i can't
understand why my string is treated as an int in the many-to-one
relationship. I have values like '0123' in the DB, but it looks like
it is treated as an int in the select(output: 123).

My entities:

public class FirstEntity
{
        public virtual int Id { get; protected set; }
        public virtual SecondEntity SecondEntity { get; set; }
        ...
}

public class SecondEntity
{
       public virtual string FirstId { get; protected set; }
       public virtual string SecondId {get; protected set; }
       ...
}

My mapping:

  <class name="FirstEntity">
    <id name="Id"></id>
    <many-to-one name="SecondEntity">
      <column name="foreignKey1"></column>
      <column name="foreignKey2"></column>
    </many-to-one>
     ...
  </class>

  <class name="SecondEntity">
    <composite-id>
      <key-property name="FirstId" />
      <key-property name="SecondId" />
    </composite-id>
    ...
  </class>

If FirstId is '0123' in the db, the values used in the sql for first
id is 123. The sq-type is varchar2 in both tables. I have tried with
type=string one the key-properties, and sql-type on the foreign keys,
but I cant get this right.

I hope somebody can help me.

Thanks.

-- 
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