-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate DetachedCriteria on Oracle CLOB
PostPosted: Mon Feb 23, 2009 11:04 am 
Newbie

Joined: Wed May 24, 2006 5:47 pm
Posts: 14
Hi.

This is my enviroment:



    JVM 1.5
    Hibernate 3.2.6
    Oracle 10g


I have a table where there is a CLOB field.
I'm able to write and read this clob field; but i'm not able to make a query by using DetachedCriteria and a filter.
Lle'ts see this sample:

Code:

String s = "Hello";

DetachedCriteria criteria = DetachedCriteria.forClass(ItemValue.class);
         criteria.add(Property.forName("fieldId").eq(
               new Integer(fieldID)));
         
      
criteria.add(Property.forName("stringValue").eq(Hibernate.createClob(s)));


In my hbm file i have:

Quote:

<property name="stringValue" type="java.sql.Clob">
<column name="STRING_VALUE" not-null="false" sql-type="CLOB"/>
</property>



Hibernate generates this query:
Code:
     select
         this_.ITEM_VALUE_ID as ITEM1_2_0_,
         this_.FIELD_ID as FIELD2_2_0_,
         this_.ITEM_ID as ITEM3_2_0_,
         this_.STRING_VALUE as STRING4_2_0_,
         this_.DATE_VALUE as DATE5_2_0_,
         this_.DOUBLE_VALUE as DOUBLE6_2_0_,
         this_.BASE_TYPE as BASE7_2_0_
     from
         item_value this_
     where
         this_.FIELD_ID=?
         and this_.STRING_VALUE=?


I get this error:
Quote:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute query
at
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630)
at
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at
org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1055)
at
org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1048)
at
it.eng.scf.cms.ce.dao.impl.EntityManager.excuteCriteria(EntityManager.java:286)
at it.eng.tz.riso2.Test2.execute(Test2.java:194)
at it.eng.tz.riso2.Test2.main(Test2.java:368)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at
org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1065)
at
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 6 more
Caused by: java.sql.SQLException: ORA-00932: inconsistent datatypes:
expected - got CLOB

at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:810)
at
oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at
oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
at
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:91)
at
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
... 13 more


Does DetachedCriteria work with CLOB fields?
If DetachedCriteria doesn't work...how can i build a select with a filter on a CLOB field?
Do u have any suggestion to solve this problem?
Thank you.
Angelo


PS: some days ago i posted the question in wrong forum section (in NHibernate section) pardon me for the error.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 6:07 am 
Newbie

Joined: Wed May 24, 2006 5:47 pm
Posts: 14
Any suggestion about my problem? I need to create a query with a filter on a CLOB field...how can i do this with Hibernate?

Thank you.
Angelo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.