getSingleResult breaks native queries
-------------------------------------
Key: EJB-414
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-414
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.4.0.GA
Environment: Hibernate 3.3.1.GA, Oracle 9i
Reporter: ChB
Mapping:
@NamedNativeQuery(name = "X", query = "{? = call XYZ(?, ?)}",
resultSetMapping = "XM", hints = { @QueryHint(name =
"org.hibernate.callable", value = "true") })
@SqlResultSetMapping(name = XM", columns = { @ColumnResult(name = "x") })
DAO:
final Query q = this.em.createNamedQuery("X");
q.setParameter(1, "whatever");
q.setParameter(2, "whatever");
final String x = (String) q.getSingleResult();
Causes hibernate to die with:
[main] org.hibernate.SQL: select * from ( {? = call XYZ(?, ?)} ) where rownum <= ?
This happens because the query (class SQLQueryImpl) has a selection.maxRows value of 2 for
no reason by the following line (QueryImpl.java:87)
if (maxResults != 1) query.setMaxResults( 2 );
This line should not be executed if the underlying query is a native query. As it will
break like shown in
http://forum.hibernate.org/viewtopic.php?p=2406045 and you have no
chance of fixing it.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira