tag:blogger.com,1999:blog-8475025587762872101.post1647757003730520244..comments2022-04-01T21:34:55.987-07:00Comments on Tadaya's Blog: Hibernate: Annotation one-to-many (foreign-key)ttddyyhttp://www.blogger.com/profile/13171169321033441226noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8475025587762872101.post-86311281243968367532010-08-18T16:24:38.225-07:002010-08-18T16:24:38.225-07:00@Vic Actually, the above solution is Hibernate spe...@Vic Actually, the above solution is Hibernate specific, this is not part of JPA 1.0. <br /><br />Using a JoinColumn on a OneToMany is <b>not</b> allowed by JPA 1.0. JPA 1.0 does <b>not</b> support unidirectional OneToMany <b>without</b> a JoinTable.<br /><br />It is possible in JPA 2.0 though.<br /><br />See the following sections of the JPA 1.0 specification:<br /><br /> - 9.1.6 JoinColumn Annotation<br /> - 2.1.8.5.1 Unidirectional OneToMany RelationshipsPascal Thiventhttps://www.blogger.com/profile/02811238537031984065noreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-12997151151476159432009-07-08T08:26:07.546-07:002009-07-08T08:26:07.546-07:00I used one-many relation for a table having one re...I used one-many relation for a table having one record(parent table) which refers to a table(having forein key ) and has two records corresponding to my primary key relation..<br />Problem is when I fetch the records of parent table the size of the record shown is 2. But I expect to have only size one since my parent table has only one record.<br />Can any one help me out of this issue?shafeer v cnoreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-75215460958234010742009-01-28T16:33:00.000-08:002009-01-28T16:33:00.000-08:00Tadaya-san,Your blog posts here were very helpful ...Tadaya-san,<BR/><BR/>Your blog posts here were very helpful in solving a strange annotation mapping problem i was having!<BR/><BR/>Domo arigato gozaimasu! :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-55765588529465186952009-01-13T23:12:00.000-08:002009-01-13T23:12:00.000-08:00it does not work with toplink (Build 060830)@OneTo...it does not work with toplink (Build 060830)<BR/><BR/>@OneToMany for attribute name [addresses] in entity class [class org.simple.jpa.core.schema.model.relationships.Person] should not have @JoinColumn(s) specified. In the case where the @OneToMany is not mapped by another entity (that is, it is the owning side and is uni-directional), it should specify (optional through defaulting) a @JoinTable.Vichttps://www.blogger.com/profile/13876094455093082780noreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-62451664645533893722008-08-20T12:11:00.000-07:002008-08-20T12:11:00.000-07:00I believe the foreign key is implied in the schema...I believe the foreign key is implied in the schema.Unknownhttps://www.blogger.com/profile/06745041157154460949noreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-9332183840379390562008-08-09T14:08:00.000-07:002008-08-09T14:08:00.000-07:00thanks, this helped me figure out how to achieve t...thanks, this helped me figure out how to achieve this. hibernate's documentation says this kind of mapping is unusal but i disagree.<BR/><BR/>@greg, the<BR/>@JoinColumn(name="personId") <BR/>on the addresses Set is what defines the fk column in the addresses table. @JoinColumn is also what tells hibernate to use a fk column as opposed to a separate table, which i tend to think is more common with many-to-many associations.Unknownhttps://www.blogger.com/profile/10471895575349179624noreply@blogger.comtag:blogger.com,1999:blog-8475025587762872101.post-49943423843948214002008-02-22T10:26:00.000-08:002008-02-22T10:26:00.000-08:00This page is called one-to-many (foreign-key) but ...This page is called one-to-many (foreign-key) but I don't see a foreign key anywhere.<BR/><BR/>I believe the address table should have a foreign key called personID. I think the line '@Column(name="personId")' in the Person class actually points to the personID foreign key in the address table.<BR/><BR/>Is this right?Greg Stouthttps://www.blogger.com/profile/05268284272484031547noreply@blogger.com