This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes First Hibernate Test Application Errors out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "First Hibernate Test Application Errors out" Watch "First Hibernate Test Application Errors out" New topic
Author

First Hibernate Test Application Errors out

Mary Chellapa
Ranch Hand

Joined: Jul 26, 2011
Posts: 93
I think my hbm.xml, cfg, and table's class and the main class are all ok but when I run the application as java application I get an error saying
Exception in thread "main" java.lang.NullPointerException
at hibTest.AddName.main(AddName.java:20)

Can somehelp.
adding the code here
testt.hbm.xml


hibernate.cfg.xml here
i have oracle database and i m omitting connection url and username and password


testt.java


AddName.java


Mary
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Line 20 of your code is this one, right?


(Check that in your Java editor. If that isn't line 20, then look at the line of code which is line 20.)

If so, that means that the "sess" variable is null. It hasn't been assigned a value.
Mary Chellapa
Ranch Hand

Joined: Jul 26, 2011
Posts: 93
yes it is, but sess.save worked so sess may not be null

but i do think the issue may be with hibernate.cfg.xml
cant figure out what
Mary Chellapa
Ranch Hand

Joined: Jul 26, 2011
Posts: 93
What should be directory structure?
is my cfg.xml placed in wrong place ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First Hibernate Test Application Errors out
 
Similar Threads
How to insert using hibernate?
ClassCastException Hibernate
hbm file version working but annotation not
Hibernate - Query Issues With Many-To-One Relationships
Insert new records in database without deleting existing records