*
The moose likes Object Relational Mapping and the fly likes Strange Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Strange Error" Watch "Strange Error" New topic
Author

Strange Error

subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
Hi all,
I am trying to execute a program to insert values into a table named Contact present in mysql. This same program was working about a two weeks back. I did not touch it for the last two weeks. Now when i run it i am getteing the following message:



The table Contact which is in MYSQL looks like the following:

Column Type
---------------------------
ID int
FIRSTNAME varchar
LASTNAME varchar
EMAIL varchar


My .hbm.xml file looks like the following:




The class Contact looks like the following:


And the class InsertExample.java in which i do the data insertion looks like the following:



What could be the reason for this output?

Kindly help.

Thanks,
Subhash
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.InsertExample.main(InsertExample.java:41)

What happens on line 41 of InsertExample?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
That line corresponds to "session.flush();". Anyway, the problem is solved now. Thanks, for your response, Paul.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So what was your error? Did the session fail to be created in the first place? Or the SessionFactory configuration fail?

Its a good idea to enclose the session.close() code in a null check to avoid this condition.
 
 
subject: Strange Error