[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2474) Hibernate doesn't support parameterized queries if the parameter is used before the where clause

SK (JIRA) noreply at atlassian.com
Wed Mar 7 06:18:31 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2474?page=comments#action_26388 ] 

SK commented on HHH-2474:
-------------------------

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: : near line 1, col
umn 1 [:col from com.album.mapping.Photo]
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.j
ava:59)
        at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.j
ava:243)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorIm
pl.java:153)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl
.java:103)
        at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.jav
a:473)
        at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1060)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1010)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:80)
        at com.album.PhotoDaoTest.testPhoto(PhotoDaoTest.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)

> Hibernate doesn't support parameterized queries if the parameter is used before the where clause
> ------------------------------------------------------------------------------------------------
>
>          Key: HHH-2474
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2474
>      Project: Hibernate3
>         Type: Improvement

>   Components: query-hql, query-sql
>     Versions: 3.2.2
>  Environment: 3.2.2, Oracle 9
>     Reporter: SK

>
>
> This works in JDBC
> 		PreparedStatement st = con.prepareStatement("select TRUNC(sysdate, ?) from dual");
> 		st.setString(1, "MM");
> 		ResultSet rs = st.executeQuery();
> A similar query doesn't work with Hibernate at present if the parameter is before the WHERE clause
> session.createSQLQuery("select TRUNC(sysdate,:truncFormat) from dual").setParameter("truncFormat", "MM").list();
> fails

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list