my dog learned polymorphism*
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