Tuesday, July 14, 2009

ORA-00932: inconsistent datatypes: expected - got BLOB

"ORA-00932: inconsistent datatypes: expected - got BLOB"
This weird single-line error in JBoss's console/log made no sense at all until I added the following snippet in the server's log4j.xml to enable Hibernate logging (thanks to Joe at the Tolven Forum):
<category name="org.hibernate.SQL">
<priority value="DEBUG"/>
</category>

(Also of course modified the server logging threshold to DEBUG)

And then came this stacktrace:

2009-07-13 18:27:47,322 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not execute query [select distinct tolvenuser0_.id as id27_, tolvenuser0_.ldapUID as ldapUID27_, tolvenuser0_.lastLogin as lastLogin27_, tolvenuser0_.creation as creation27_, tolvenuser0_.status as status27_, tolvenuser0_.sponsorship_id as sponsor19_27_, tolvenuser0_.timeZone as timeZone27_, tolvenuser0_.locale as locale27_, tolvenuser0_.emailFormat as emailFor8_27_, tolvenuser0_.demoUser as demoUser27_, tolvenuser0_.likeness_id as likeness18_27_, tolvenuser0_.pbeKeyAlgorithm as pbeKeyA10_27_, tolvenuser0_.salt as salt27_, tolvenuser0_.iterationCount as iterati12_27_, tolvenuser0_.encodedEncryptedPrivateKeyInfo as encoded13_27_, tolvenuser0_.PRIVATE_KEY_SIZE as PRIVATE14_27_, tolvenuser0_.PRIVATE_KEY_ALGORITHM as PRIVATE15_27_, tolvenuser0_.x509EncodedKeySpec as x16_27_, tolvenuser0_.PUBLIC_KEY_ALGORITHM as PUBLIC17_27_ from tolven.TolvenUser tolvenuser0_ where tolvenuser0_.ldapUID=? and (tolvenuser0_.status='ACTIVE' or tolvenuser0_.status='active' or tolvenuser0_.status='new' or tolvenuser0_.status='ACTIVATING' or tolvenuser0_.status='')]
java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected - got BLOB

at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
at org.tolven.security.bean.LoginBean.findUser(LoginBean.java:73)
at org.tolven.security.bean.LoginBean.createOrUpdateUser(LoginBean.java:314)
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:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:86)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)
at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:115)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:795)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
2009-07-13 18:27:47,338 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 932, SQLState: 42000
2009-07-13 18:27:47,338 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-00932: inconsistent datatypes: expected - got BLOB


Once the erring query was out in the open (in bold above), I tried executing it in an SQL window and identified that the error was being thrown on those columns of this table that were of type BLOB.
And Google quickly told me that Oracle doesn't like using "SELECT DISTINCT..." on any BLOB columns of a table. Voila!

No comments:

Post a Comment

 
Superblog Directory