Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1504

type mapping for boolean in finder wrong

XMLWordPrintable

      i have defined a finder in which i will test a boolean attribute, but i got a database error that the datatype must be compatibel.

      In EJBQL i have tested "attribute = false" and the generated SQL says "attribute = 0", that is wrong cause MaxDB wants "attribute = false".

      I have changed the mapping in standardjbosscmp-jdbc.xml to BOOLEAN but that changed nothing.

      I have defined a new mapping for MaxDB in standardjbosscmp-jdbc.xml:

      <type-mapping>
      <name>MaxDB</name>
      <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
      <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
      <fk-constraint-template>ALTER TABLE ?1 ADD FOREIGN KEY ?2 (?3) REFERENCES ?4 (?5)</fk-constraint-template>
      <auto-increment-template>?1</auto-increment-template>
      <alias-header-prefix>t</alias-header-prefix>
      <alias-header-suffix>_</alias-header-suffix>
      <alias-max-length>32</alias-max-length>
      <subquery-supported>true</subquery-supported>
      <true-mapping>1</true-mapping>
      <false-mapping>0</false-mapping>

      <function-mapping>
      <function-name>count</function-name>
      <function-sql>count(?1)</function-sql>
      </function-mapping>

      <mapping>
      <java-type>java.lang.Integer</java-type>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Character</java-type>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>CHAR</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.String</java-type>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(256)</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Object</java-type>
      <jdbc-type>JAVA_OBJECT</jdbc-type>
      <sql-type>LONG BYTE</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Byte</java-type>
      <jdbc-type>TINYINT</jdbc-type>
      <sql-type>CHAR BYTE</sql-type>
      </mapping>
      <mapping>
      <java-type>java.sql.Timestamp</java-type>
      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>TIMESTAMP</sql-type>
      </mapping>
      <mapping>
      <java-type>java.util.Date</java-type>
      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>TIMESTAMP</sql-type>
      </mapping>
      <mapping>
      <java-type>java.sql.Time</java-type>
      <jdbc-type>TIME</jdbc-type>
      <sql-type>TIME</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Boolean</java-type>
      <jdbc-type>BOOLEAN</jdbc-type>
      <sql-type>BOOLEAN</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Float</java-type>
      <jdbc-type>FLOAT</jdbc-type>
      <sql-type>FLOAT</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Short</java-type>
      <jdbc-type>SMALLINT</jdbc-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Double</java-type>
      <jdbc-type>DOUBLE</jdbc-type>
      <sql-type>DOUBLE PRECISION</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Long</java-type>
      <jdbc-type>DECIMAL</jdbc-type>
      <sql-type>DECIMAL(20)</sql-type>
      </mapping>
      </type-mapping>

      <type-mapping>
      <name>Cloudscape</name>
      <row-locking-template/>
      <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
      <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
      <alias-header-prefix>t</alias-header-prefix>
      <alias-header-suffix>_</alias-header-suffix>
      <alias-max-length>32</alias-max-length>
      <subquery-supported>true</subquery-supported>
      <true-mapping>1</true-mapping>
      <false-mapping>0</false-mapping>

      <function-mapping>
      <function-name>count</function-name>
      <function-sql>count(?1)</function-sql>
      </function-mapping>

      <mapping>
      <java-type>java.math.BigDecimal</java-type>
      <jdbc-type>LONGVARCHAR</jdbc-type>
      <sql-type>LONG VARCHAR</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Boolean</java-type>
      <jdbc-type>BIT</jdbc-type>
      <sql-type>BOOLEAN</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Byte</java-type>
      <jdbc-type>TINYINT</jdbc-type>
      <sql-type>TINYINT</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Short</java-type>
      <jdbc-type>SMALLINT</jdbc-type>
      <sql-type>SMALLINT</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Integer</java-type>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Long</java-type>
      <jdbc-type>BIGINT</jdbc-type>
      <sql-type>LONGINT</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Float</java-type>
      <jdbc-type>REAL</jdbc-type>
      <sql-type>REAL</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Double</java-type>
      <jdbc-type>DOUBLE</jdbc-type>
      <sql-type>DOUBLE PRECISION</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Character</java-type>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>CHAR</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.String</java-type>
      <jdbc-type>LONGVARCHAR</jdbc-type>
      <sql-type>LONG VARCHAR</sql-type>
      </mapping>
      <!-- NOTE: This alternative mapping has been suggested for cloudscape
      <mapping>
      <java-type>java.lang.String</java-type>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(256)</sql-type>
      </mapping> -->
      <mapping>
      <java-type>java.sql.Date</java-type>
      <jdbc-type>DATE</jdbc-type>
      <sql-type>DATE</sql-type>
      </mapping>
      <mapping>
      <java-type>java.sql.Time</java-type>
      <jdbc-type>TIME</jdbc-type>
      <sql-type>TIME</sql-type>
      </mapping>
      <mapping>
      <java-type>java.sql.Timestamp</java-type>
      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>TIMESTAMP</sql-type>
      </mapping>
      <mapping>
      <java-type>java.lang.Object</java-type>
      <jdbc-type>JAVA_OBJECT</jdbc-type>
      <sql-type>LONG VARBINARY</sql-type>
      </mapping>
      </type-mapping>

      Here a part of the log:

      2005-02-23 10:20:40,364 DEBUG org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.Type#findNonInternalByTypeClass Executing SQL: SELECT t0_o.id FROM TYPE t0_o, TY
      PE t1_o_typeClass WHERE (t1_o_typeClass.type = ? AND t1_o_typeClass.xinternal = 0 AND t0_o.TYPE_CLASS_ID=t1_o_typeClass.id)
      2005-02-23 10:20:40,382 ERROR org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.Type#findNonInternalByTypeClass Find failed
      com.sap.dbtech.jdbc.exceptions.DatabaseException: [-8006] (at 114): Data types must be compatible
      at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:71)
      at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:830)
      at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:489)
      at com.sap.dbtech.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1646)
      at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:778)
      at com.sap.dbtech.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:234)
      at com.sap.dbtech.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:185)
      at com.sap.dbtech.jdbc.CallableStatementSapDB.<init>(CallableStatementSapDB.java:87)
      at com.sap.dbtech.jdbc.ConnectionSapDB.prepareStatement(ConnectionSapDB.java:722)
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:355)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:205)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:190)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:128)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.execute(JDBCFindEntitiesCommand.java:40)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntities(JDBCStoreManager.java:598)
      at org.jboss.ejb.plugins.CMPPersistenceManager.findEntities(CMPPersistenceManager.java:322)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.java:321)
      at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:649)
      at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1113)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:192)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:117)
      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.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:126)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:99)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508)
      at org.jboss.ejb.Container.invoke(Container.java:891)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:342)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      at $Proxy131.findNonInternalByTypeClass(Unknown Source)
      at de.oblgmbh.wb.meta.ejb.WBMetaFacadeBean.getTypeNonInternalByTypeClass(Unknown Source)
      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:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
      at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:870)
      at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)

              olubyans@redhat.com Alexey Loubyansky
              ibruell_jira Ingo Bruell (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: