- This topic has 6 replies, 2 voices, and was last updated 19 years, 2 months ago by
Haris Peco.
-
AuthorPosts
-
mwunderlichMemberDear all,
Well, as the subject line says, I am looking for any good tutorials or instructions on how to use MyEclipse code generation/reverse engineering to create associations. At present I am working manually on the Hibernate mapping files, which works, but is a bit cumbersome. I’d guess there are better solutions out there. Any hints?
Cheers,
Martin
April 14, 2006 at 8:59 am #250479
Haris PecoMemberMartin,
You need make your connection profile, select some tables and call ‘Hibernate mapping’ action – You will got wizard where you can choose option for your work (except all, you can add related tables – tables with FKs and imported keys).Wizard will make your assotiation (bidirectional if it possible)
Best
April 14, 2006 at 9:23 am #250483
mwunderlichMemberThanks for the reply, snpe.
I checked the wizard thoroughly and I can’t see where exactly I would specify the relations between the tables and the type of association (one-to-one, many-to-many etc.). I see only type mappings in the second screen and table/column details in the third screen.
Also, when I have a foreign key in one table, how would MyEclipse know which table this FK references? Does ME create association tables for many-to-many relations automatically? If not, where and how to specify which association table relates to which association?
Cheers,
Martin
April 14, 2006 at 10:34 am #250492
Haris PecoMemberMartin,
MyEclipse will make relation for all tables with FK keys (MyEclipse read data from database dictionary with jdbc metadata)
We don’t support many-to-many for now, but it will be added in future releases.It is hard decide what is many-to-many because it is logical concepts (it doesn’t exists in relational databases – many-to-many are 3 tables with 2 FK relations in databases)
You can’t specify relation, now – just call wizard and you will see what MyEclipse make – it is all FK relation (and PK like ID).I don’t sure what you want specify yet.Best regards
April 14, 2006 at 11:17 am #250496
mwunderlichMemberHi snpe,
I got it working now. MyEclipse is automatically generating the mappings and bidi associations for me. Very, very nice. The missing info was that I first need to explicitly specify the foreign key when I am creating my database tables. (I also learnt that in MySQL you need to index the foreign key column, before adding the FK).
Thanks a lot for your help.Cheers,
Martin
April 14, 2006 at 12:31 pm #250499
mwunderlichMemberJust one more remark after playing around a bit more: It would be nice, if it were possible to specify the directionality of the associations. In my case I end up with a good bit of superfluous code (when one class at one of the association doesn’t have to know about the other end). For instance, the wizard could present the user with a preview list of all possible associations. For each association, there is a check box for bidi yes/no and if no, which direction.
Cheers,
Martin
April 14, 2006 at 3:53 pm #250502
Haris PecoMemberMartin,
you have make foreign key you can add ‘add index’ clause.It isn’t necessary for MySQL >= 5.0
MyEclipse make all associations for you, but you have use lazy loading (association isn’t loaded until you try access)
We will think about adding choice yes/no for associations in future releasesThank you for your feedback and I’m glad for your success
Best regards
-
AuthorPosts