These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NPE when trying to get uniqueResult from sproc (sql server)
PostPosted: Fri Sep 16, 2011 12:01 pm 
Newbie

Joined: Fri Sep 16, 2011 11:53 am
Posts: 1
I have this in my mapping:
Code:
   <sql-query name="sprocName" callable="true">
      <return-scalar column="userId" type="integer"/>
      <![CDATA[
      { call sprocName(
          :param1,
          :param2,
          :param3,
          :param4,
          :param5,
          :param6
      )}
      ]]>
    </sql-query>


My java code is as below

Code:
    Query query = HibernateUtil.getNamedQuery(
      "com.voyager.vip.dao.LicenseSystemUserDao.consumeStaffLicense");   
     
   
    query.setInteger("param1", param1);
    query.setInteger("param3", param2);
    query.setDate("param3", param3);
    query.setInteger("param4", param4);
    query.setInteger("param5", param5);
    query.setInteger("param6", param6);
   
    Integer r = (Integer)query.uniqueResult();


In end of my sproc I execute this sproc this:
Code:
.
.
.
.
   set @sql = 'select UserId from Table where UserId=12354'
   exec sp_executesql @sql
   print @sql



when I execute the code, I can see in the log that the call is made by Hibernate to the sproc but I get a NullPointerException

Code:
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)


Could someone please help, guide me in some direction. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.