- This topic has 8 replies, 5 voices, and was last updated 20 years ago by
support-jeff.
-
AuthorPosts
-
rbandeiraMemberHi all again!
I am very new in hibernate and java, and i would appreciate some help or example that someone have.
I have a simple many-to-many association! Like Orders and Itens and we create a Orders_Itens table with two PKs like OrderID and ItensID.
How can i create the mapping file for this situation?
And the java class? How am i create this?!?!?Thanks,
Raphael Bandeira.June 20, 2005 at 1:26 pm #231388
Riyad KallaMemberRaphael,
Please take a look at our quickstart guide here:
http://www.myeclipseide.com/images/tutorials/quickstarts/hibernate/June 21, 2005 at 11:15 am #231466
fergumanMemberHi,
The quickstart guide doesn’t tell one how to create classes that contain one to many associations to other classes (eg. Invoices with one or more Items on them). At least I don’t see how the quickstart guide could tell one since it only deals with one database table (that isn’t self referential ;-).
Can the Hibernate tools help create java classes that contain sets/lists of other related classes?
Thanks
Joe
June 22, 2005 at 5:54 pm #231585
support-jeffMemberjoe –
only the inverse side of a many-to-one relationship. many-to-many is not supported in the autogeneration tools at this time.
July 5, 2005 at 9:21 am #232287
ahbrown41MemberHow about one to many as you mentioned? I selected all my tables in the explorer, the tables are connected via a few one to many foreign keys in MySQL. The generated code did not take this into account. What does it use to generate this mappings? Does it explore the foreign keys, is it name based?
Thanks!
July 5, 2005 at 4:41 pm #232323
support-jeffMemberNo, the current version does not support any relationships other than the many-to-one side of things.
July 5, 2005 at 10:39 pm #232341
ahbrown41MemberSorry Jeff, just to be clear. I mentioned a one to many relationship and you mentioned a many to one relationship. As far as I understand it, these are the same depending on the how you look at it. From the db foreign key they are the same, one address can have one country but one country can have many addresses right? So if this is supported, what mechanism does it use for doing this link? Foreign keys or column names? Or, does it only support doing a mapping for a single table and does not take into account the relations of other tables?
Thanks.
July 5, 2005 at 10:42 pm #232342
ahbrown41MemberTo be clear, I am not talking about many to many relationships in any way 🙂 I understand that is not supported.
July 6, 2005 at 7:10 am #232357
support-jeffMemberCurrently the tool only supports mapping relationships as a many-to-one entry in the mapping file for the table that has the FK, not its inverse in the related table (the one-to-many collection association). If you need more info on the difference, please take a look at the documentation on the hibernate web site:
-
AuthorPosts