[jboss-user] [JBoss Tools (users)] - Re: Hibernate reverse engineering errors
bdlink
do-not-reply at jboss.com
Fri Mar 6 13:23:00 EST 2009
Thanks for responding so quickly.
With respect to some of my questions that were unclear:
1. JoinTables can map 1-1 and 1-n as well as n-n. I was not clear on how to reverse engineer this situation.
2. I can use the same primary key in both tables to make a 1-1 relation. This wants a @PrimaryKeyJoinColumn(s) annotation instead of @JoinColumn. I was not clear how to reverse engineer this situation.
I understand that it would be a lot of work to add everything! I had understood from the original Hibernate books years ago that the philosophy was that you could use three strategies with Hibernate:
1. Annotate the Java
2. write an hbm.xml
3. reverse engineer the db metadata
choosing which ever one suited the situation (and whichever one you write, the other two will be generated). Since the database metadata does not contain enough information to generate the other two, you need to help that case with reveng.xml.
I understood the ultimate goal would be that there are equal capabilities with all three strategies. If not, we should say that one of these is the best practice, but the others can be useful at times (since the world seems to be moving away from xml, I guess that the Java annotations would have to be primary?)
Java Persistence with Hibernate, Bauer and King, indicate that the above three strategies are feasible (and recommend 2 only for the seasoned Hibernate expert). Also Dan Allen's Seam in Action book gives the three strategies.
So I would not be put out of reveng.xml became as big as hbm.xml :) However, at the moment, I would be happy if I could clearly understand what exactly is possible, and what would be nice but is not there.
Further information on the error (this is H11 update installed) By the way, where do I look to find the hibernate-reverse-engineering-3.0.dtd?:
reveng.xml file (all but foreign-key elements generated by wizard):
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
|
| <hibernate-reverse-engineering>
| <table-filter match-catalog="infosys" match-name="review" />
| <table-filter match-catalog="infosys" match-name="student" />
| <table-filter match-catalog="infosys" match-name="team" />
| <table-filter match-catalog="infosys" match-name="user_auth" />
| <table-filter match-catalog="infosys" match-name="user_roles" />
| <table-filter match-catalog="infosys" match-name="xuser" />
| <table catalog="infosys" name="team">
| <column name="name" jdbc-type=''></column>
| <column name="year" jdbc-type=''></column>
| <column name="leaderId" jdbc-type='' property="leader"></column>
| <foreign-key constraint-name="team_ibfk_1"><one-to-one property="leader"/></foreign-key>
| </table>
| <table catalog="infosys" name="student">
| <column name="studentNumber" jdbc-type=''></column>
| <column name="setLetter" jdbc-type=''></column>
| <column name="year" jdbc-type=''></column>
| <column name="CSTOption" jdbc-type=''></column>
| <column name="teamId" jdbc-type='' property="tesm"></column>
| <column name="userId" jdbc-type='' property="user"></column>
| <foreign-key constraint-name="student_ibfk_1"><many-to-one property="team"/><set property="members"/></foreign-key>
| <foreign-key constraint-name="student_ibfk_2"><one-to-one property="user"/></foreign-key>
| </table>
| <table catalog="infosys" name="review">
| <column name="employee" jdbc-type=''></column>
| <column name="pos" jdbc-type=''></column>
| <column name="reviewer" jdbc-type=''></column>
| <column name="received" jdbc-type=''></column>
| <column name="period" jdbc-type=''></column>
| <column name="year" jdbc-type=''></column>
| <column name="reviewType" jdbc-type=''></column>
| <column name="tech1" jdbc-type=''></column>
| <column name="rateTech1" jdbc-type=''></column>
| <column name="tech2" jdbc-type=''></column>
| <column name="rateTech2" jdbc-type=''></column>
| <column name="tech3" jdbc-type=''></column>
| <column name="rateTech3" jdbc-type=''></column>
| <column name="tech4" jdbc-type=''></column>
| <column name="rateTech4" jdbc-type=''></column>
| <column name="rateTask1" jdbc-type=''></column>
| <column name="rateTask2" jdbc-type=''></column>
| <column name="rateTask3" jdbc-type=''></column>
| <column name="rateTask4" jdbc-type=''></column>
| <column name="rateTask5" jdbc-type=''></column>
| <column name="rateTask6" jdbc-type=''></column>
| <column name="rateTask7" jdbc-type=''></column>
| <column name="rateTask8" jdbc-type=''></column>
| <column name="ratePersonal1" jdbc-type=''></column>
| <column name="ratePersonal2" jdbc-type=''></column>
| <column name="ratePersonal3" jdbc-type=''></column>
| <column name="ratePersonal4" jdbc-type=''></column>
| <column name="ratePersonal5" jdbc-type=''></column>
| <column name="ratePersonal6" jdbc-type=''></column>
| <column name="ratePersonal7" jdbc-type=''></column>
| <column name="ratePersonal8" jdbc-type=''></column>
| <column name="rateLeadership1" jdbc-type=''></column>
| <column name="rateLeadership2" jdbc-type=''></column>
| <column name="rateLeadership3" jdbc-type=''></column>
| <column name="rateLeadership4" jdbc-type=''></column>
| <column name="summary" jdbc-type=''></column>
| <column name="comments" jdbc-type=''></column>
| <foreign-key constraint-name="review_ibfk_1"><many-to-one property="employee"/></foreign-key>
| <foreign-key constraint-name="review_ibfk_2"><many-to-one property="reviewer"/></foreign-key>
| </table>
| <table catalog="infosys" name="xuser" class="User" schema="">
| <column name="lastName" jdbc-type=''></column>
| <column name="firstName" jdbc-type=''></column>
| <column name="userName" jdbc-type=''></column>
| <column name="userIsActive" jdbc-type=''></column>
| <column name="email" jdbc-type=''></column>
| <column name="emailIsPublic" jdbc-type=''></column>
| <column name="website" jdbc-type=''></column>
| <column name="employer" jdbc-type=''></column>
| <column name="employerWebSite" jdbc-type=''></column>
| <column name="pictureFile" jdbc-type=''></column>
| <column name="description" jdbc-type=''></column>
| <foreign-key constraint-name="xuser_ibfk_1"><one-to-one property="userAuth" exclude="true"/></foreign-key>
| </table>
| <table catalog="infosys" name="user_roles" class="UserRole">
| <column name="userName" jdbc-type=''></column>
| <column name="userRoles" jdbc-type='' property="userRole"></column>
| <foreign-key constraint-name="user_roles_ibfk_1"><many-to-one exclude="true"/></foreign-key>
| </table>
| <table catalog="infosys" name="user_auth">
| <column name="passwd" jdbc-type=''></column>
| </table>
| </hibernate-reverse-engineering>
|
stacktrace:
!ENTRY org.hibernate.eclipse.console 4 666 2009-03-06 09:31:55.046
| !MESSAGE org.hibernate.MappingException: Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml
| !STACK 0
| org.hibernate.MappingException: Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:119)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:296)
| at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
| at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:94)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:285)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
| at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:865)
| at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1068)
| at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
| Caused by: org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:157)
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:115)
| ... 11 more
| Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at java.lang.String.charAt(String.java:558)
| at org.hibernate.mapping.Table.setSchema(Table.java:617)
| at org.hibernate.cfg.reveng.OverrideBinder.bindTables(OverrideBinder.java:103)
| at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:46)
| at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:170)
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:149)
| ... 12 more
| !SUBENTRY 1 org.hibernate.eclipse.console 4 666 2009-03-06 09:31:55.046
| !MESSAGE org.hibernate.MappingException: Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml
| !STACK 0
| org.hibernate.MappingException: Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:119)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:296)
| at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
| at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:94)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:285)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
| at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:865)
| at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1068)
| at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
| Caused by: org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:157)
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:115)
| ... 11 more
| Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at java.lang.String.charAt(String.java:558)
| at org.hibernate.mapping.Table.setSchema(Table.java:617)
| at org.hibernate.cfg.reveng.OverrideBinder.bindTables(OverrideBinder.java:103)
| at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:46)
| at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:170)
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:149)
| ... 12 more
| !SUBENTRY 1 org.hibernate.eclipse.console 4 666 2009-03-06 09:31:55.046
| !MESSAGE org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| !STACK 0
| org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:157)
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:115)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:296)
| at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
| at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:94)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:285)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
| at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:865)
| at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1068)
| at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
| Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at java.lang.String.charAt(String.java:558)
| at org.hibernate.mapping.Table.setSchema(Table.java:617)
| at org.hibernate.cfg.reveng.OverrideBinder.bindTables(OverrideBinder.java:103)
| at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:46)
| at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:170)
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:149)
| ... 12 more
| !SUBENTRY 1 org.hibernate.eclipse.console 4 666 2009-03-06 09:31:55.046
| !MESSAGE java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| !STACK 0
| java.lang.StringIndexOutOfBoundsException: String index out of range: 0
| at java.lang.String.charAt(String.java:558)
| at org.hibernate.mapping.Table.setSchema(Table.java:617)
| at org.hibernate.cfg.reveng.OverrideBinder.bindTables(OverrideBinder.java:103)
| at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:46)
| at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:170)
| at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:149)
| at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:115)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:296)
| at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
| at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:94)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:285)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:218)
| at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:138)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
| at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
| at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:865)
| at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1068)
| at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4215819#4215819
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4215819
More information about the jboss-user
mailing list