Hibernate Version: 2.1.2
with Oracle 9i
I added a computed formula to one of my mappings that REQUIRES a bind variable:
Code:
<property
name="formulatedMessage"
type="java.lang.String"
update="true"
insert="true"
formula="decode(id,?,'Yes','No')"
/>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="none">
<generator class="assigned">
</generator>
</id>
and I want to execute an HQL query where I can pass in a value for that bind variable. It looks like
Code:
String query = "from " + BlobTestBean.class.getName();
Query hqlQuery = sess.createQuery(query);
hqlQuery.setParameter(0, new Integer(1), Hibernate.INTEGER);
List resultSet = hqlQuery.list();
When I run the code snippet above, I get an exception
Code:
java.lang.IllegalArgumentException: No positional parameters in query: from com.qrs.itm.dao.BlobTestBean
at net.sf.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:137)
at com.qrs.itm.dao.BlobTest.testRetrieveFormulatedValue(BlobTest.java:157)
...
and when I run the test above and comment out the line where the positional parameter is set, I get an exception from Oracle:
Code:
java.sql.SQLException: ORA-01008: not all variables bound
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
...
Does Hibernate support a feature like this? Are there newer versions of Hibernate that do?
FYI, I'm happy with the SQL being produced which is:
Code:
2004-05-26 17:51:00,315 [main] DEBUG net.sf.hibernate.hql.QueryTranslator - HQL: from com.qrs.itm.dao.BlobTestBean
2004-05-26 17:51:00,315 [main] DEBUG net.sf.hibernate.hql.QueryTranslator - SQL: select blobtestbe0_.id as id, blobtestbe0_.msg as msg, blobtestbe0_.bytes as bytes, decode(blobtestbe0_.id,?,'Yes','No') as f0_ from BlobTest blobtestbe0_
2004-05-26 17:51:00,331 [main] DEBUG net.sf.hibernate.SQL - select blobtestbe0_.id as id, blobtestbe0_.msg as msg, blobtestbe0_.bytes as bytes, decode(blobtestbe0_.id,?,'Yes','No') as f0_ from BlobTest blobtestbe0_
Thanks, Steve