Bugs item #533686, was opened at 2002-03-23 04:26
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=533686&group_id=22866

Category: JBossCMP
Group: v3.0 Rabbit Hole
Status: Open
Resolution: None
Priority: 5
Submitted By: Peter Levart (plevart)
Assigned to: Dain Sundstrom (dsundstrom)
Summary: JDBCStartCommand.tableExists() Oracle

Initial Comment:
This is not realy a bug, rather a workarround for a 
peculiarity of the Oracle DB using thin JDBC driver.

When deploying Entity Beans on Oracle (using thin 
driver - I haven't tried with the full blown native 
version), the JDBCStartCommand.tableExists() 
incorrectly returns false when the table already 
exists and deployment later fails when JBoss is 
trying to create the table.

The problem is that table names in Oracle DB seem to 
be UPPER CASE ONLY. But the 
java.sql.DatabaseMetadata.getTables() that is used in 
JDBCStartCommand.tableExists() to check for the 
existense of a particular table, uses a 
tableNamePattern that performs a case-sensitive 
search. So if you specify the table name as 
"SomeBean" then the actual table created on the 1st 
deployment would be "SOMEBEAN" and later deployments 
will fail.

One workarround is to simply use UPPER CASE ONLY 
names for tables when deploying on Oracle, the other 
would be for JDBCStartCommand.tableExists() to check 
for the existence of table with exact given name and 
for a table with an UPPER CASE NAME.

I'm including the later as a patch attached to the 
bug report...


----------------------------------------------------------------------

Comment By: Stephen Coy (scoy)
Date: 2002-04-07 17:28

Message:
Logged In: YES 
user_id=463096

I retract my comment about this being an Oracle bug. 
Oracle in fact allows mixed-case table name identifiers.

It is possible to have three different tables:
  TEST
  Test
  test

I believe that the correct solution is to always bracket 
table names with the result of 
DatabaseMetaData.getIdentifierQuoteString().

ie. we then use queries such as:

  create table "test" ("id" NUMBER)

and

  select "id" from "test"

Databases that don't support quoted identifiers are 
supposed to return a space " " from the 
getIdentifierQuoteString call.

According to the docs for getIdentifierQuoteString, a 
JDBC Compliant driver always uses a double quote 
character.



----------------------------------------------------------------------

Comment By: Stephen Coy (scoy)
Date: 2002-04-07 14:10

Message:
Logged In: YES 
user_id=463096

Doh!
There doesn't seem to be a way to attach files in 
followups. I know this is not ideal:

Index: JDBCStartCommand.java
===========================================
========================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/
plugins/cmp/jdbc/JDBCStartCommand.java,v
retrieving revision 1.22
diff -r1.22 JDBCStartCommand.java
193c193,198
<          rs = dmd.getTables(con.getCatalog(), null, 
tableName, null);
---
>          String physicalTableName = tableName;
>          if (dmd.storesUpperCaseIdentifiers())
>               physicalTableName = 
tableName.toUpperCase();
>          else if (dmd.storesLowerCaseIdentifiers())
>               physicalTableName = 
tableName.toLowerCase();
>          rs = dmd.getTables(con.getCatalog(), null, 
physicalTableName, null);


----------------------------------------------------------------------

Comment By: Stephen Coy (scoy)
Date: 2002-04-07 13:59

Message:
Logged In: YES 
user_id=463096

Here's an alternative patch that exploits the database 
metadata to check if case conversion is needed for 
identifiers.
However, I agree that this is really a bug in the Oracle 
implementation of 'getTables'.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=533686&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to