- This topic has 12 replies, 4 voices, and was last updated 18 years, 2 months ago by Intax.
-
AuthorPosts
-
jcastellMemberIt would be very nice to be able to change the name of the hibernate mapping file for a table when reverse engineering Hibernate and Spring classes/configs. Due to a truly Byzantine DB naming convention enforced by a very pushy and powerful DBA group, we end up getting gibberish when table names are transformed into hbm.xml files. We’d like to be able to reverse engineer a table called T_SMD_ACT_ORD and name the mapping something like OpenOrders.hbm.xml, and other artifacts automatically named OpenOrders*.* (you get the idea).
-jc
Riyad KallaMemberJC,
I believe this was discussed internally, I’m checking with the Hib guys.
Riyad KallaMemberJC,
In MyEclipse 5.0.1 on the 3rd page of the reverse engineering wizard you should be able to set the custom class names, which are also used to name the HBM.XML files.
jcastellMemberRiyad,
I’m running ME 5.0.1, and it seems that it doesn’t matter what I choose as the class name for a table. The names of the generated artifacts are still based onb the table name.
-jc
Brian FernandesModeratorJC,
Are there any errors in your log? You might have an invalid RE configuration file which is causing your customizations to be skipped.
More details on the error log can be found here: [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL].You could try creating a new RE file on the 2nd page of the RE wizard.
Let us know how it goes,
Brian.
jcastellMemberApologies for the delay, but I’ve been traveling for a while.
I think I may have found something. I updated the hibernate DTD file to the latest version a while ago, and this is causing some issues with RE. Specifically, ME reverse engineers the <primary-key> Hibernate elements with <column> subelements. But in the latest Hibernate DTD, <primary-key> elements require <key-column> subelements, not <column> elements. The RE still works in the sense that all artifacts are created, but the revenge.hibernate.xml file that gets created is invalid for the new DTD.
Is there any consideration on your part for another 5.0 series patch? One that might upgrade the Hibernate libraries to 3.1.4 or later?
Lemme know,
-jc
Riyad KallaMemberJC, yes we are starting to plan the 5.0.3 release here internally and hope to have it done by the end of October.
Brian FernandesModeratorJC,
The DTD we include in our internal catalogs is the DTD that our Hibernate Tools support. If you change this DTD, I’m afriad things will really not work and we cannot support this. This is very likely why you’re experiencing these issues.
Could you tell us how you replaced our version with the latest version – did you replace the file within your MyEclipse installation?
If you could replace the DTD with the original version, things should work. I’d advise not directly modifying the hibernate.reveng.xml file but using our RE wizard to do so. You might want to start with a new Reverse Engineering file as well to avoid confusion.
The latest stable version of Hibernate in the 3.1 stream is Hibernate 3.1.3, which we ship in 5.0. I’d just like to point out that Hibernate and Hibernate Tools are different, the reveng.xml DTD belongs to the latter, we will hopefully be upgrading these tools in an upcoming release.
Best,
Brian.
jcastellMemberApologies for the delay in getting back.
While I was away, I reverted the DTD for Hibernate reverse engineering to the original. That cleared up some things, but I’m still seeing the same behavior. Namely, I do the following:
1) Right-click on a table to be reverse engineered in the ME Hibernate perspective.
2) On page 1 of the RE wizard, I select the options to generate an abstract parent pojo, and Spring DAO.
3) On page 2, I don’t enter anything.
4) On page 3, I enter a FQCN for the class to correspond to the table. That class name has little or no resemblance to the table name. I also map each column by hand.The hbm.xml file that gets generated is based on the table name, as are the abstract and concrete pojos, as well as the Spring DAO.
-jc
Brian FernandesModeratorJC,
I investigated this further and I found a bug in the persistence of that FQN in the reveng settings file. When you re-invoke the wizard and go to page 3, and drill down to the table, do you see the FQN you entered the last time there? If it isn’t there then it isn’t being saved to the reveng.xml file correctly (this is a bug and will be fixed in 5.0.3). However, if you do see the FQN and it is still not being respected, ignore the rest of this post and let us know.
To correct this situation, you need to change the ID Generator property at the same time you change the FQN. This will get the your FQN persisted. You can re-invoke the RE wizard and delete reset or delete the ID Generator to what it originally was.
A second option is to edit the hibernate.reveng.xml file in the XML editor, and add the class attribute to your table element.
e.g.<table name="tableName" catalog="catName" class="com.foo.MyNewClass">
You should already have a table element for each table as you mentioned you are mapping each column by hand (I assume this is working?)
Note: You may have schema attribute instead of catalog, or both schema and catalog attributes depending on your database.I apologize for the inconvenience caused, do let us know if you still experience issues.
Brian.
IntaxMemberHi,
I found the same behaviour. The custom class name I entered is stored in the reveng file – editing the ID Generator property doesn’t make any difference. The custom class name is completely ignored, the table name is used.
Pavel
Brian FernandesModeratorPavel,
I assume that when you go to page 3 of the wizard, you see your classname already specified for the table in question (please confirm)? If so, the ID generator property is irrelevant, it only forces the storage of that property. Are you specifying the fully qualified class name?
Please post your error log here, you might have some invalid entires in the reveng file which is causing all settings in the entire file to be skipped (this will be logged). More instructions and questions here: Posting Guidelines
Best,
Brian.
IntaxMemberBrian,
well, next time I’ll read the log first. It contains the following exception:
!ENTRY com.genuitec.eclipse.hibernate 1 0 2006-10-16 09:33:02.296
!MESSAGE Error processing rev-eng settings file
!STACK 0
org.hibernate.MappingException: Could not configure overrides from file: C:\Documents and Settings\rp\Plocha\eclip_5GA_My\workspace\xxx\hibernate.reveng.xml
at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:79)
at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:272)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Caused by: org.hibernate.MappingException: invalid override definition
at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:108)
at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:75)
… 2 more
Caused by: org.xml.sax.SAXParseException: The content of element type “sql-type” must match “EMPTY”.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
blahblahblahthe reveng file contains
<sql-type jdbc-type=”DECIMAL”
hibernate-type=”java.math.BigDecimal”>
</sql-type>
when I change it to
<sql-type jdbc-type=”DECIMAL”
hibernate-type=”java.math.BigDecimal”></sql-type>
or to
<sql-type jdbc-type=”DECIMAL”
hibernate-type=”java.math.BigDecimal”/>
everything works well. I suppose this was a bug in some early version of MyEclipse, as now the wizzard generates a correct description (for the new mappings).Thank you and best regards,
Pavel -
AuthorPosts