Bugs item #849681, was opened at 2003-11-26 15:37
Message generated for change (Comment added) made by aboud
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=849681&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Olivier Abdoun (aboud)
Assigned to: Alexey Loubyansky (loubyansky)
Summary: SQL user-defined types not supported

Initial Comment:
Symptom:
when creating a CMP entity bean with a geometry field
in Oracle 9i, an SQLException (Invalid column type:
sqlType=2002) occurs

Details:
- I use an Oracle 9.2 database with the ojdbc14.jar /
oci driver
- the geometry CMP field has the following description:
ejb-jar.xml:
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>geometry</field-name>
         </cmp-field>
jbosscmp-jdbc.xml:
         <cmp-field>
            <field-name>geometry</field-name>
            <column-name>GEOMETRY</column-name>

            <jdbc-type>STRUCT</jdbc-type>
            <sql-type>MDSYS.SDO_GEOMETRY</sql-type>

        </cmp-field>
- the stack trace is:
13:45:41,727 ERROR [LogInterceptor] EJBException, causedBy:
java.sql.SQLException: Invalid column type: sqlType=2002
        at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
        at
oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:1308)
        at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setNull(WrappedPreparedStatement.java:356)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.setParameter(JDBCUtil.java:1188)
        at
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters(JDBCAbstractCMPFieldBridge.java:338)
        at
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setInstanceParameters(JDBCAbstractCMPFieldBridge.java:320)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:291)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:144)
        at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:518)
        at
org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:208)
        at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:269)
        at
org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1042)
        at
org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
        at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197)
        at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214)
        at
org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
        at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89)
        at
org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
        at
org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
        at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98)
        at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
        at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
        at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
        at
org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:484)
        at org.jboss.ejb.Container.invoke(Container.java:720)
        at
org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:293)
        at
org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
        at $Proxy70.create(Unknown Source)

Explanation:
the Oracle MDSYS.SDO_GEOMETRY datatype is a
user-defined STRUCT. the error occurs because the
geometry field is initialized to NULL using:
    ps.setNull(index, java.sql.Types.STRUCT)
(JDBCUtil.java line line 1188) instead of calling the
user-defined types compatible version of
PreparedStatement.setNull:
    ps.setNull(index, java.sql.Types.STRUCT,
"MDSYS.SDO_GEOMETRY")


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

>Comment By: Olivier Abdoun (aboud)
Date: 2003-11-26 16:17

Message:
Logged In: YES 
user_id=124177

I figured out the problem using a direct JDBC call:

ps.setNull(idx, STRUCT) ==> SQLException

ps.setNull(idx, STRUCT, "MDSYS.SDO_GEOMETRY") ==> OK

Yes, indeed, it's the driver that enforces the use of this
version of setNull, but reading the javadoc for
PreparedStatement I don't think it can be called a bug: it
is said that the use of the typeName in setNull is for
portability issue with user defined types...

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

Comment By: Alexey Loubyansky (loubyansky)
Date: 2003-11-26 15:57

Message:
Logged In: YES 
user_id=543482

Isn't it a driver problem? Can you do it with direct JDBC
yourself?

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

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


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to