-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Help annotation OneToMany with a composite key
PostPosted: Fri Mar 20, 2009 11:05 am 
Newbie

Joined: Fri Mar 20, 2009 10:24 am
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 23, 2009 4:32 am 
Newbie

Joined: Fri Mar 20, 2009 10:24 am
Posts: 2
up


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.