facebook

Good tutorials on creating Hibernate associations with ME?

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #250476 Reply

    mwunderlich
    Member

    Dear 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

    #250479 Reply

    Haris Peco
    Member

    Martin,

    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

    #250483 Reply

    mwunderlich
    Member

    Thanks 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

    #250492 Reply

    Haris Peco
    Member

    Martin,

    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

    #250496 Reply

    mwunderlich
    Member

    Hi 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

    #250499 Reply

    mwunderlich
    Member

    Just 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

    #250502 Reply

    Haris Peco
    Member

    Martin,

    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 releases

    Thank you for your feedback and I’m glad for your success

    Best regards

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Good tutorials on creating Hibernate associations with ME?

You must be logged in to post in the forum log in