• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Odd NullPointerException

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
}
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic