Setting length on composite -key property

Andrew's Avatar

Andrew

08 Dec, 2010 04:45 PM via web

This is a follow up to an existing closed discussion which can be found here.

Ive compiled the latest trunk and I'm able to set the Type/Length properties, however when I export the schema to SQL Server I end up with two varchar(255) fields. Ive included the mapping I'm using to try and get this working.

Table("DummyTable");
CompositeId()
    .KeyProperty(x => x.Id1, kp => kp.ColumnName("Id1").Type("AnsiString").Length(4))
    .KeyProperty(x => x.Id2, kp => kp.ColumnName("Id2").Type("AnsiString").Length(4));

Might be something obvious Im doing wrong as Im fairly new to all this.

  1. 2 Posted by Andrew on 08 Dec, 2010 05:24 PM

    Andrew's Avatar

    Adding the mapping it generated, the lengths clearly look ok here but not in the SQL database.

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true">
      <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="NHibernateTest.Model.Dummy, NHibernateTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="DummyTable">
        <composite-id mapped="false" unsaved-value="undefined">
          <key-property name="Id1" type="AnsiString" length="4">
            <column name="Id1" />
          </key-property>
          <key-property name="Id2" type="AnsiString" length="4">
            <column name="Id2" />
          </key-property>
        </composite-id>
      </class>
    </hibernate-mapping>
    

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is two plus two?