-->
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.  [ 4 posts ] 
Author Message
 Post subject: Query gives java.lang.NullPointerException
PostPosted: Tue Mar 22, 2005 2:58 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0rc1

Code between sessionFactory.openSession() and session.close():

Code:
numDeleted =
HibernateUtil.getSession()
.createQuery("delete from UserChange where userId = :userId").
setString("userId", userId)
.executeUpate();


The error is showing on the line having
Code:
executeUpate()


NOTE:HibernateUtil.java is available from http://caveatemptor.hibernate.org

The generated SQL (show_sql=true):

480822be SystemOut O Hibernate: select userchange0_.USER_CHANGE_SET_ID as USER1_0_, userchange0_.USER_CHG_TIMESTAMP as USER2_4_0_, userchange0_.USER_ID as USER3_4_0_, userchange0_.AUDIT_LOG_ID as AUDIT4_4_0_ from UA_RULE.USER_CHANGE_SET userchange0_ where userchange0_.USER_CHANGE_SET_ID=?


Debug level Hibernate log excerpt:

[3/22/05 13:28:52:969 EST] [3/22/05 13:28:53:660 EST] 480822be parser E hql.parser *** ERROR: <AST>:0:0: unexpected end of subtree
[3/22/05 13:28:53:660 EST] 480822be parser E hql.parser *** ERROR: <AST>:0:0: unexpected end of subtree
[3/22/05 13:28:53:670 EST] 480822be SystemErr R

Name and version of the database you are using:
DB2 8.1

Full stack trace of any exception that occurs:

java.lang.NullPointerException
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.path(HqlSqlBaseWalker.java:2193)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2281)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2232)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:498)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.deleteStatement(HqlSqlBaseWalker.java:276)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:156)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:801)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at org.hibernate.impl.QueryImpl.executeUpate(QueryImpl.java:89)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at com.lmig.vmd_web.dao.UserChangeDAO.delete(UserChangeDAO.java:197)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at com.lmig.vmd_web.test.UserChangeTest.deleteTestData(UserChangeTest.java:160)
[3/22/05 13:28:53:670 EST] 480822be SystemErr R at com.lmig.vmd_web.test.UserChangeTest.runTests(UserChangeTest.java:38)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at org.apache.jsp._test._jspService(_test.java:96)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
[3/22/05 13:28:53:681 EST] 480822be SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
[3/22/05 13:28:53:691 EST] 480822be SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 24, 2005 12:31 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
I used this instead:

Code:
List tempChangeList = getUserChangeList(userId);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
               
for(Iterator it=tempChangeList.iterator();it.hasNext();)
{   
    HibernateUtil.beginTransaction();
    HibernateUtil.getSession().delete( (UserChange)it.next() );

}



This works, but is inefficient. Why doesn't the delete query work?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 5:26 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
It should be "delete UserChange " instead of "delete from UserChange".


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 7:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Wouldn't it make a *lot* more sense to be using 3.0.2 instead of 3.0rc1?

P.S. "delete from" is allowed.


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

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.