facebook

Hibernate Mapping and Application Generation with Views

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

    jthomas8
    Participant

    I have been following the MyEclipse Hibernate Tutorial and everything is working great except when I try to map a View to Hibernate instead of a Table.

    DB2 has length limits on table and column names. So we create tables and columns with short names then create Views for all the tables with more meaningful names.

    Using the “Hibernate Mapping and Application Generation” wizard works great for the tables but when I try it with the Views the code generated is not correct and it always adds an additional Java class for the ID value of each table (ViewNameId.java).

    Is there someway to make the wizard work with Views as well as Tables?

    #307383 Reply

    Brian Fernandes
    Moderator

    jthomas,

    Could you paste the code that is generated for you and point out the changes you would like made? I will ask our persistence team to take a look at this.

    #307395 Reply

    jthomas8
    Participant

    My problem was I was not defining my Primary and Foreign Keys in the hibernate.reveng.xml file.

    Once I started doing this my views worked correctly.

    My next question is, is there a way to automatically add these definition to the hibernate.reveng.xml file or must I always do this manually?

    #307488 Reply

    Brian Fernandes
    Moderator

    jthomas,

    I’m not sure I understand – once added to hibernate.reveng.xml, you do not need to do this again for that given view. When you say “must I always do this manually” do you mean for other views you RE from? If so – yes, you do need to this manually for each view.

    We already have this tracked internally, but I will increase the priority on this so that it is possible to make these settings through the RE wizard itself, without having to manually edit the reveng.xml file.

    Please let me know if that will satisfy your requirements, thank you for asking.

    #307490 Reply

    jthomas8
    Participant

    When I said “must I always do this manually” I met for every view I want to RE. You are correct that once I add them to the hibernate.reveng.xml I do not have to add them again.

    Correct me if I’m wrong but can’t the wizard look up the table the view is for and figure out the primary and foreign keys automatically?

    The other thing I noticed when using the RE wizard is the “Include referenced tables (A -> B)” and “Include referenced tables (A <- B)” options on page 3 of the wizard do not work with views.

    #307491 Reply

    Brian Fernandes
    Moderator

    Thanks for the quick clarification.

    Correct me if I’m wrong but can’t the wizard look up the table the view is for and figure out the primary and foreign keys automatically?

    The other thing I noticed when using the RE wizard is the “Include referenced tables (A -> B)” and “Include referenced tables (A <- B)” options on page 3 of the wizard do not work with views.

    Views are not always subsets of a single table, you could have an aggregation of data, multiple tables, etc.; so it may definitely be possible to do this in some cases, but not in all.

    #307492 Reply

    jthomas8
    Participant

    Good point. I was thinking more along the lines of views that represent a single table and are setup for the sole purpose of having more readable names. I have several views which combine multiple tables but I wouldn’t want to RE them.

    Thanks for the replies.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Hibernate Mapping and Application Generation with Views

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