For the last couple of years, I have been trying hibernate reverse engineering on a test database with seam-gen or JBT. It is improving, but does not work out of the box. (work, in terms of generating examples that will compile). I think all of the issues are in JIRA.
At the moment I am trying to get the hibernate.reveng.xml to customize the reverse engineering so it will be as desired. I have read the Hibernate Tools Reference Guide version 3.2.4.CR2 from the JBoss Tools CR2 Doc site, as well as the one at Hibernate.org (which is quite similar). Neither has a detailed reference on how to specify the reverse engineering of relationships. The hibernate reverse engineering editor (part of Hibernate tools) does not seem to deal with this aspect, so I have been trying to use the source window to add <foreign-key> elements appropriately.
I get the following error when I try to generate the entities:
Exception while generating code Reason: org.hibernate.MappingException: Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml Could not configure overrides from file: C:\apps\workspace3.4.2\infosys-ejb\.settings\hibernate.reveng.xml org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 java.lang.StringIndexOutOfBoundsException: String index out of range: 0 org.hibernate.MappingException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 java.lang.StringIndexOutOfBoundsException: String index out of range: 0 java.lang.StringIndexOutOfBoundsException: String index out of range: 0 String index out of range: 0
This is using 3.0.x branch nightly on top of eclipse 3.4.2
Unfortunately, this error does not help me figure out what I did wrong.
I am currently searching for the DTD, but if there is some more detailed documentation I have not found, that would be appreciated.
A useful addition to the documentation would be examples of how to reverse engineer:
1. OneToOne unidirectional
2. OneToOne bidirectional
3. OneToMany unidirectional
4. ManyToOne unidirectional
5. OneToMany bidirectional
6. ManyToMany unidirectional
7. ManyToMany bidirectional
How should one reverse engineer JoinTable mapping in all of the above, as well as foreign key mapping, and primary key join columns where those are appropriate?
Is it possible to specify how to handle composite primary keys (@IdClass vs. @EmbeddedId)?
Also, how to specify the type of collection (Collection, Set, List, Map)?
Also wonderful would be how to reverse engineer inheritance strategies (SINGLE_TABLE, TABLE_PER_CLASS, JOINED)
Finally, is it possible to reverse engineer an entity with properties from multiple tables (@SecondaryTable)?
The reason for all of these questions, is that there is the large ripple effect to generated artifacts when the relationships are not as desired. The current default seems to aggressively add reverse engineered relationships (even in the absence of foreign key constraints in the DB), so knowing how to eliminate undesired ones is also important.