Details
-
Bug
-
Resolution: Done
-
Major
-
JBossAS-3.2.6 Final
-
None
Description
SourceForge Submitter: jlrobins_sserve .
Deploying a CMP entity with the jbosscmp-jdbc.xml tag for
tablename set containaing the name of the preexisting database
schema for the table to be built in, such as:
<table-name>agency.category</table-name>
<create-table>true</create-table>
will always try to create the table, since
org.jboss.ejb.plugins.cmp.jdbc.SQLUtil's tableExists()
method does not split out the schema portion of the name into the
separate parameter mandated by DatabaseMetaData's getTables().
Calling getTables() with null for schemas:
... null means that the schema name should not be used to
narrow the search (from DriverMetaData javadoc)
yet it seems to imply that the table name portion should be the
simple name, not fully-qualified. Using Postgresql JDBC driver,
when given null for schema and "agency.category" for table name,
it always returns an empty result set, since no one table's non-
fullly-qualified name is 'agency.category' – very different from
schema named 'agency' and table named 'category' (in postgres's
eyes, anyway).
This causes JBoss to always try to create the table, causing
deployment failure on all but the first deployment.
Fix would be to sniff the passed-in table name for a '.', and split
into schema vs. table name on the period.
Patch attached to fix places in SQLUtil where getTables is called w/o
sniffing to split fully qualified table name into schema + table. The
patch is relative to SQLUtil version 1.12.4.19.