File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate prepared statement is replacing values with question mark Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate prepared statement is replacing values with question mark" Watch "Hibernate prepared statement is replacing values with question mark" New topic
Author

Hibernate prepared statement is replacing values with question mark

manjesh yadav
Greenhorn

Joined: Aug 07, 2012
Posts: 1
We are using Hibernate 3 with WebSphere v6 and DB2. We are having strange issue with wrong SQL prepared statements issued by Hibernate and causing syntax issues.

Good query issued by Hibernate:

SELECT * FROM rocc.Transaction t WHERE t.status_cd = 0 and t.application_cd = ? order by coalesce(t.priority,0) fetch first 25 rows only

Same query issued by Hibernate incorrectly sometimes:

SELECT * FROM rocc.Transaction t WHERE t.status_cd = ? AND t.application_cd = ? ORDER BY COALESCE(t.priority,?) FETCH first ? ROWS ONLY

It is replacing values(zero) with question mark and changing font of the keywords to uppercase (it does not matter, but mentioning here). It also changed the number 25 in fetch clause with question mark.

What is causing with the wrong prepared statement issued by Hibernate sometimes?

Hibernate is calling WSJdbcPreparedStament.executeQuery method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate prepared statement is replacing values with question mark
 
Similar Threads
how to get limited record in hql?
Exception:com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: W
SQL question
weird Db2exception
COALESCE Function in TIMESTAMP