This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
 
 
subject: Hibernate prepared statement is replacing values with question mark
 
Similar Threads
SQL question
weird Db2exception
how to get limited record in hql?
Exception:com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: W
COALESCE Function in TIMESTAMP