Friday, May 4, 2007

Using seam-gen.reveng.xml to control tables used for entity generation

I was having problems using seam-gen to try out reverse engineering on an Oracle Express database. Seam-gen was finding all sorts of objects somehow exposed to the user, rather than the DEMO_ tables I was trying to generate off of. Turns out that a feature (undocumented?) was added in 1.2.1.GA that let's you use a reveng.xml file to control this. After you run:

C:\temp\jboss-seam-1.2.1.GA>seam new-project

You can go to the \resources\seam-gen.reveng.xml

And add a line such as this:
<table-filter match-schema="MYSCHEMA" match-name="DEMO.*" exclude="false"/>

This should effectively restrict the tables as desired. Note you can use multiple of these entries to "carve out" the set of tables you want (although I'm not sure what the exact semantics are of using various combinations of exclude=true/false for different entries).

Some things to watch out for:
  • Case sensitivity
    At least for Oracle, you need to use upper case (I suppose you could attemp some kind of case insensitive regex).
  • Owning schema in seam-gen.reveng.xml
    Seems like you have to specify the owning schema for the tables, even if you are connecting with a user that has privileges for the tables.
  • Owning schema in
    You need to specify connection properties to the owning schema, at least temporarily, or you may get WARNING: Exception while trying to get indexinfo on...
I haven't tried enough variations to prove all of the above bullets, but if you're experiencing problems, try out some of these suggestions.

Reference for table-filter

No comments: