- This topic has 6 replies, 2 voices, and was last updated 14 years, 8 months ago by jthomas8.
-
AuthorPosts
-
jthomas8ParticipantI 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?
Brian FernandesModeratorjthomas,
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.
jthomas8ParticipantMy 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?
Brian FernandesModeratorjthomas,
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.
jthomas8ParticipantWhen 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.
Brian FernandesModeratorThanks 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.
jthomas8ParticipantGood 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.
-
AuthorPosts