| Author |
Null Pointer Exception using DAO, Hibernate and Struts
|
Monica Salvador
Greenhorn
Joined: Feb 24, 2011
Posts: 23
|
|
Hello.
When I query the Loanapplications from the HQL, it shows a result, but when I use the DAO, it returns a Null Pointer Exception. Please help.
|
 |
Deepakkumar Devarajan
Ranch Hand
Joined: Apr 19, 2011
Posts: 50
|
|
|
Could you please post your error message as text and releated code
|
Regards,
Deepakkumar Devarajan
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
Welcome to the Javaranch.
As Deepakkumar suggests, your error message would be easier to read as text. If you are not going to post all your code, it would be good to indicate which line in your code is the one indicated by the error message.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Monica Salvador
Greenhorn
Joined: Feb 24, 2011
Posts: 23
|
|
the one that generates the error is the code:
loanapplist = session.createQuery("from Loanapplications").list();
through my further exploration of the error, i have found out that the variable session is null. i used the @SessionTarget annotation though and i am using hibernate. the other DAO's are working fine, but my loanapplicationDAO is not.
|
 |
Monica Salvador
Greenhorn
Joined: Feb 24, 2011
Posts: 23
|
|
|
|
 |
Deepakkumar Devarajan
Ranch Hand
Joined: Apr 19, 2011
Posts: 50
|
|
Monica Salvador wrote:the one that generates the error is the code:
loanapplist = session.createQuery("from Loanapplications").list();
You said in your first post that you are able to query the Loanapplications successfully using HQL but you mentioned the same line causing the issue. Do you mean loanapplist is null even after successful execution of the query??
|
 |
Monica Salvador
Greenhorn
Joined: Feb 24, 2011
Posts: 23
|
|
|
no. the session is null.
|
 |
Manuel Schenkhuizen
Greenhorn
Joined: Apr 20, 2011
Posts: 14
|
|
an easy way to solve your problem.
you can print the elements of your list before return and see what you have got.
i think the problem may be not the nullpoint of you list.
|
 |
 |
|
|
subject: Null Pointer Exception using DAO, Hibernate and Struts
|
|
|