Hi,
I use NHibernate.Mapping.Attributes for mapping declarations and SchemaExport class for generating ddl. I've noticed that HbmSerializer always places <many-to-one> elements after <property> element. It's a real pain for me if I declare multicolumn unique keys or indexes with property and foreign key column. I cannot set correct column order:
Hibernate version: 1.2.0 Alpha 1
Class definition:
Code:
[Class]
public class Course
{
private int _id;
[Id(0, Column="Id", TypeType = typeof(int) )]
[Generator(1, Class = "native")]
public virtual int Id
{
get { return _id; }
set { _id = value; }
}
private Product _product;
[ManyToOne(0, ForeignKey="FK_Course_Product"),
Column(1, Name = "ProductID", NotNull=true, UniqueKey = "0")]
public virtual Product Product
{
get { return _product; }
set { _product = value; }
}
private string _name;
[Property (0),
Column(1, Name = "Name", NotNull = true, Length=50, UniqueKey = "0")]
public virtual string Name
{
get { return _name; }
set { _name = value; }
}
}
Xml generated by HbmSerializer :Code:
<class name="Test.Domain.Course, Test.Core">
<id column="Id" type="Int32">
<generator class="native" />
</id>
<property name="Name">
<column name="Name" length="50" not-null="true" unique-key="0" />
</property>
<many-to-one name="Product" foreign-key="FK_Course_Product">
<column name="ProductID" not-null="true" unique-key="0" />
</many-to-one>
</class>
I expect unique key (ProductID, Name) so I need <column name="ProductID">
before <column name="Name">. How can I perform this?