This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Odd NullPointerException

 
subhashchandra medhiassam
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
subhashchandra medhiassam
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have sorted out the problem. I had not included some of the jars. Thanks for the help anyway.

Subhash
 
Lei Guoguo
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic