Hello,
I hope you'll help me :), i tried for 4 hours to work with annotation and i want to make a "inner join" between 2 tables which contains composite keys.
I give you the structure of both tables and explain you how i map the relations
First table (table1)
Code:
[code_site] [nvarchar](4) NOT NULL PRIMARY KEY
[code_rest] [nvarchar](4) NOT NULL PRIMARY KEY
[code_cais] [nvarchar](2) NOT NULL PRIMARY KEY
[no_ticket] [int] NOT NULL PRIMARY KEY
Second table (table2)
Code:
[code_site] [nvarchar](4) NOT NULL PRIMARY KEY
[code_rest] [nvarchar](4) NOT NULL PRIMARY KEY
[code_cais] [nvarchar](2) NOT NULL PRIMARY KEY
[no_ticket] [int] NOT NULL PRIMARY KEY
[no_ordre] [int] NOT NULL PRIMARY KEY
I tried to map the relations like this :
For Table1
Code:
[Bag(0,Name = "Table2DO", Cascade = CascadeStyle.None, Inverse = true, Generic = true, Lazy = true)]
[Property(1, Name = "Id")]
[Property(2, Name = "CodeRest")]
[Property(3, Name = "CodeCais")]
[Property(4, Name = "NoTicket")]
[KeyManyToOne(5, Column = "code_site")]
[KeyManyToOne(6, Column = "code_rest")]
[KeyManyToOne(7, Column = "code_cais")]
[KeyManyToOne(8, Column = "no_ticket")]
[KeyManyToOne(9, Column = "no_ordre")]
[OneToMany(10, Class = "Table2DO")]
public virtual IList<Table2DO> Table2{
get {
return table2;
}
set {
table2= value;
}
}
For table2
Code:
[Property(1, Name = "Id")]
[Property(2, Name = "CodeRest")]
[Property(3, Name = "CodeCais")]
[Property(4, Name = "NoTicket")]
[ManyToOne(5, Class = "Table1", Lazy = Laziness.Proxy, NotNull = false)]
public virtual Table1DO Table1{
get {
return table1;
}
set {
table1= value;
}
}
Unfortunetaly, the mapping didn't pass, i found no documentation how it works with annotations...
How to map the inner join relation with composite id ?, i'm sure it's a syntax problem.
I have this Exception :
Element 'bag' in namespace 'urn:nhibernate-mapping-2.2' has a not valid child element 'one-to-many'.
Thanks in advance for your help.
Brice.