-->
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.  [ 4 posts ] 
Author Message
 Post subject: Composed ID and ManyToOne
PostPosted: Mon Apr 25, 2005 11:07 am 
Newbie

Joined: Thu Apr 14, 2005 8:06 am
Posts: 2
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0
Mapping documents:
hibernate-annotations-3.0beta1
Full stack trace of any exception that occurs:
org.hibernate.MappingException: Foreign key (FK8C537FB2372ADF72:Table4 [IdT1,IdT2,field])) must have same number of columns as the referenced primary key (Table3 [field])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:86)
at org.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:51)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:952)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:897)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:167)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1048)

My Entitys
Code:
Table1
   idT1
   field1
   field2
   
Table2
   idT2
   field1
   field2
   
   
Table3
   @Id
    public Table3PK getComp_id() {return this.comp_id;}
    public void setComp_id(Table3PK comp_id) { this.comp_id = comp_id; }
   
    field1
    field2

   

Table3PK
   @ManyToOne
   @JoinColumn(name="idT1")
    public Table1 getTable1() { return this.table1;}
    public void setTable1(Table1 table1) { this.table1 = table1; }
   
   @ManyToOne
   @JoinColumn(name="idT2")
    public Table2 getTable2() { return this.table2;}
    public void setTable2(Table2 table2) { this.table2 = table2; }

   @Column(name="field")
    public Integer getField() { return this.field; }
    public void setCdProced(Integer field) { this.field = field; }
   
Table4
    .
    .
    .
   @ManyToOne
    @JoinColumns ({
       @JoinColumn(name="idT1"),
       @JoinColumn(name="idT2"),
       @JoinColumn(name="field")
    })
    public Table3 getTable3() { return this.table3;}
    public void setTable3(Table3 table3) { this.table3 = table3; }

   


When I trying make a ManyToOne of Table4 to Table3 where Table3 has a compose_id and ManyToOne inside, is throw the Exception above,
but, if I change Table3PK removing @ManyToOne inside

Table3PK without ManyToOne
Code:
Table3PK
   @Column(name="idT1")
    public Integer getIdT1() { return this.idT1;}
    public void setIdT1(Integer idT1) { this.idT1 = idT1; }
   
   @Column(name="idT2")
    public Integer getIdT2() { return this.idT2;}
    public void setIdT2(Integer idT2) { this.idT2 = idT2; }

   @Column(name="field")
    public Integer getField() { return this.field; }
    public void setCdProced(Integer field) { this.field = field; }   

then work fine.

Anybody can help me.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 5:33 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Using @ManyToOne inside an embedded object is currently not possible. Any patch welcome :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 7:08 am 
Newbie

Joined: Thu Apr 14, 2005 8:06 am
Posts: 2
Hello emmanuel

tks for reply, I going to wait for this patch.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 12:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
mauro_schneider wrote:
tks for reply, I going to wait for this patch.

Hum, that's not the answer I would expect ;-)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.