openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Null schema name when generating tables?
Date Thu, 16 Aug 2007 14:46:36 GMT
Hi,
Looking for a pointer in case somebody knows this code better than me...

We're running the CTS TCK against DB2 and we've hit a snag with the
SynchronizeMappings feature (I know this is not a required aspect of the
TCK, but that's what we have been using to create the tables for the
testing).

One of the tests in the TCK requires a table called DATATYPES.  The problem
is that DB2 has a system table by this name, so when OpenJPA attempts to
look up any existing table information, we accidentally find the system
table (SYSCAT) instead of the user's table (cts1).  The following trace
snippet shows the problem.

1000  JPATCK  TRACE  [main] openjpa.jdbc.Schema - Reading table information
for schema name "null", table name "DATATYPES".
1000  JPATCK  TRACE  [main] openjpa.jdbc.JDBC - <t 16515324, conn
1314410072> [0 ms] rollback
1000  JPATCK  TRACE  [main] openjpa.jdbc.JDBC - <t 16515324, conn
1314410072> getColumns: null, null, DATATYPES, null
1500  JPATCK  TRACE  [main] openjpa.jdbc.Schema - Reading column information
for table " SYSCAT.DATATYPES".

Of course, this goes on thinking that we have found an appropriate DATATYPES
table definition, but later when we attempt to alter it, we get an error:

1891  JPATCK  TRACE  [main] openjpa.jdbc.SQL - <t 16515324, conn 477240434>
executing stmnt 854733554 ALTER TABLE DATATYPES ADD id INTEGER
1891  JPATCK  TRACE  [main] openjpa.jdbc.SQL - <t 16515324, conn 477240434>
[0 ms] spent
1891  JPATCK  TRACE  [main] openjpa.jdbc.JDBC - <t 16515324, conn 477240434>
[0 ms] close
<openjpa-0.0.0-r420667:563705M nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: DB2 SQL error: SQLCODE:
-204, SQLSTATE: 42704, SQLERRMC: CTS1.DATATYPES {stmnt 854733554 ALTER TABLE
DATATYPES ADD id INTEGER} [code=-204, state=42704]

I started to debug the problem and am finding that we are relying on the
setting of a schema name either via annotation or xml to override the
default of "null".

The question I have is whether this could be changed to pull the userid from
the Connection object, if the configured schema name is null, of course.
This way, if the user has configured a schema name, it would be used.  But,
if no schema name is configured, then we would use the userid of the
Connection object.  If there is no security associated with a given database
(ie. Derby), this would still default to null and we'd be processing as we
do today.  But, in the case of secure databases (ie. DB2, Oracle, etc), we
would use the userid from the Connection object.

Would there be a problem with this approach?

Thanks,
Kevin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message