- This topic has 2 replies, 1 voice, and was last updated 18 years, 7 months ago by Steve Prior.
-
AuthorPosts
-
Steve PriorMemberWith the following settings entered in db reverse engineering:
<hibernate-reverse-engineering>
<table name=”tvchannel_rtab” catalog=”tv” class=”Channel”>
<primary-key>
<generator class=”assigned”></generator>
</primary-key>
</table>
<table name=”tvdescription_rtab” catalog=”tv” class=”Description”>
<primary-key>
<generator class=”native”></generator>
</primary-key>
</table>
<table name=”tvepisode_rtab” catalog=”tv” class=”Episode”>
<primary-key>
<generator class=”native”></generator>
</primary-key>
</table>
<table name=”tvprogram_rtab” catalog=”tv” class=”Program”>
<primary-key>
<generator class=”native”></generator>
</primary-key>
</table>
<table name=”tvshow_rtab” catalog=”tv” class=”Show”>
<primary-key>
<generator class=”native”></generator>
</primary-key>
</table>
</hibernate-reverse-engineering>When generated the hibernate mapping from my TV database the generated classes didn’t match the classes
I specified above, for example tvprogram_rtab was still generated as Java POJO class TvprogramRtab.I was certainly under the impression that the class generated would be Program instead. I’m using MySQL 5,
MyEclipse 4.1.1 which I upgraded from the update site on top of a fresh 4.1 install. Is there any chance the move from 4.1GA to 4.1.1GA needs a fresh install instead of an update (I hope not)?
Steve PriorMemberI don’t know what the problem was, but it’s working a little better now, the class names are being used.
I believe there is still a problem though, albeit with a workaround. I specified a package that the classes should be generated in just like I did with MyEclipse 4.1. However, it seems that if you specify a class name for each table you need to specify the full classname including package for each class or else they get generated in the default package. I believe this is a little counter-intuitive – I had specified a package for the generated files, and the field for overriding the class name implied to me that all I was changing was the class name, not the package AND class name.I am very happy that the class override was added (once I figured out the little quirk above). If I had this feature a month ago it would have saved me an entire days worth of work when I reverse engineered a fair sized project with a decent number of tables and LOTS of foreign keys interconnecting them. I spent a whole day renaming classes and relationship members.
Steve PriorMemberI hate updating myself like this in this thread, but I just looked and noticed that while the
class names are overridden, the private members and public accessor methods for object relationships
aren’t using the overridden classnames.For example I have a table TrafficUser_rtab and TrafficUserRule_rtab. In the reverse engineering
settings I specified the first use class name “User” and the second be named “UserRule”. The classes
themselves are named fine, but UserRule has a foreign key to User and the generated member
got named:private Set trafficuserRuleRtabs = new HashSet(0);
public Set getTrafficuserRuleRtabs() {
return this.trafficuserRuleRtabs;
}public void setTrafficuserRuleRtabs(Set trafficuserRuleRtabs) {
this.trafficuserRuleRtabs = trafficuserRuleRtabs;
}when due to my name override I would have expected:
private Set userRules = new HashSet(0);
public void setUserRules(Set userRules) {
…
}So clearly the relationship reverse engineering is ignoring the class name overrides. Renaming this kind
of stuff is what used up a lot of that day I mentioned for that bigger project.BTW, it would be wonderful if refactor->rename would also update hibernate mapping files…
-
AuthorPosts