| Author |
Odd NullPointerException
|
subhashchandra medhiassam
Ranch Hand
Joined: Sep 10, 2008
Posts: 72
|
|
Dear friends,
I have run into a problem and need your help in solving it.
I am trying to map the values of the fields of an object into a relational database table.
The file hibernate.cfg.xml looks like the following :
The POJO class named ContactDetails.java looks like the following :
And the class used to set the values into the POJO is named as FirstExample.java. It looks like the following:
But when i execute FirstExample.java, i am getting a NulPointerException corresponding to the statement session.flush(); which is in the finally block.
What should i do now ? Kindly help me out.
Subhash
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
So most likely your session is not created in the first place. Have a look at your logs, there should be another error message in there.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
subhashchandra medhiassam
Ranch Hand
Joined: Sep 10, 2008
Posts: 72
|
|
Hi,
I have sorted out the problem. I had not included some of the jars. Thanks for the help anyway.
Subhash
|
 |
Lei Guoguo
Greenhorn
Joined: Mar 31, 2009
Posts: 26
|
|
subhashchandra medhiassam wrote:Dear friends,
But when i execute FirstExample.java, i am getting a NulPointerException corresponding to the statement session.flush(); which is in the finally block.
What should i do now ? Kindly help me out.
Subhash
you can try in this way:
......
finally {
if(session != null) {
session.flush();
session.close();
session = null;
}
}
|
I'm a chinese, my english is so bad, I need help. If you want to help me, you can send your question to my e-mail: lgg860911@yahoo.com.cn, I will help you, and improve my english. Thanks everyone.
|
 |
 |
|
|
subject: Odd NullPointerException
|
|
|