- This topic has 8 replies, 5 voices, and was last updated 19 years, 5 months 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.
Riyad KallaMemberRaphael,
Please take a look at our quickstart guide here:
http://www.myeclipseide.com/images/tutorials/quickstarts/hibernate/
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
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.
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!
support-jeffMemberNo, the current version does not support any relationships other than the many-to-one side of things.
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.
ahbrown41MemberTo be clear, I am not talking about many to many relationships in any way 🙂 I understand that is not supported.
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