Hi,
Couldn't find information from either documentation or forum (or was confused by my laziness)... And I'm a bit puzzled right now.
During our regular development process on a product, each developper has access to its own schema, containing its own data, so he can tweak schema/content without harming anyone else.
Of course, production and staging environment also have their own schema.
Noone is directly tied to a particular DB repository (or server), just a schema.
Now, we do a complete reverse-engineering process for data classes, involving JDBC configuration and java generation.
It means that the 'schema' information is something only relevant during runtime, and can only read from "local properties" (or parameters).
We also need to access some 'external' (third-parties) tables lying in a separate schema.
This "default-schema" selection (and database selection) is done through a hibernate property-file created by ant.
Many problems arose during the process:
1. We couldn't specify a valid schema-selection. The reveng file must have some schema-selection tags in it, but there is no way to make it use the "default-schema".
Note that we can't use 'all schemas' since some third-parties might be installed multiple times in the same DB (using different schemas) and still be readable by everyone (and sharing the same tables). Again, the accessed schema is defined at runtime.
The only way I found to perform this, is to specify each table "by-hand" using its own <schema-selection> without schema parameter !
For example:
This doesn't work (too many tables found, or no table found):
Code:
<schema-selection/> // <= finds 100+ tables, including NICROMAN.NPO_INFO, MATE.NPO_INFO....
or
<schema-selection match-table="NPO.*"/> // <= finds nothing at all !
But this is working:
Code:
<schema-selection match-table="NPO_INFO"/>
Of course, the above means that we are not using table-filter since all tables are added "by-hand"
2. All generated hbm.xml files do come with a 'schema' value, meaning that each code generated is tied to a particular schema.
The only way ot override this was to use a home-grown tool to rip-off those schema information.
3. It is not possible to use the <table> tags in the reveng file, since it requires a schema parameter (or it doesn't work, according to own experience and the multiple messages in this forums on this subject), and... we don't know it ! ;)
Of course, the worse thing about this is that we cannot use views at all since we can't tell reverse-engineering what PK to use for that particular view.
Note that it would be possible to "cook" the reveng file at build time, and set all schema values to the right thing, but this is not solving point (2), nor point (1).