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 named query to execute sproc on sql server NPE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate named query to execute sproc on sql server NPE" Watch "Hibernate named query to execute sproc on sql server NPE" New topic
Author

Hibernate named query to execute sproc on sql server NPE

Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
Hi
I'm trying to execute a sql server stored procedure via hibernate named query. However get the exception below when I do query.list(). Other sprocs are executed similarly and work just fine. THanks

java.lang.NullPointerException
at org.hibernate.loader.custom.CustomLoader$Metadata.<init>(CustomLoader.java:544)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:517)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1817)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
I also tried this:

sql-query name="sprocName" callable="true">
<return-scalar column="newId" type="integer"/>
...


Returned a 1 as constant in the sproc.

and did a query.uniqueResult()

and now I get this

Unhandled exception
java.lang.NullPointerException
at org.hibernate.loader.Loader.doQuery(Loader.java:720)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)

 
wood burning stoves
 
subject: Hibernate named query to execute sproc on sql server NPE