Meaningless Drivel is fun!*
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
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)

 
Consider Paul's rocket mass heater.
 
subject: Hibernate named query to execute sproc on sql server NPE
 
Similar Threads
problem using hibernate and stored procedures for reading portion of data from database
java.sql.SQLException: Parameter #1 has not been set. with hibernate/sybase/jtds executing StoreP
Hibernate Exception: Could not extract result set metadata
Problem Named Queries In Hibernate
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9