aspose file tools
The moose likes Object Relational Mapping and the fly likes Null Pointer Exception @ SessionFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Null Pointer Exception @ SessionFactory" Watch "Null Pointer Exception @ SessionFactory" New topic
Author

Null Pointer Exception @ SessionFactory

Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Hello to everyone,

I'm new to Hibernate. I just want to do a sample project with Hibernate. But I've been taking exceptions, I'll be happy if someone can help me..
Thanks in advance..

And here's my hibernate.cfg.xml file:

Full stacktrace:
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26499
    
  78

Talha,
The exception says it is being thrown in line 30 in saveOrUpdate. Which line is line 30? If I had to guess, I would imagine it is one of the lines in the catch or finally block. You should have a null check so you aren't trying to rollback the transaction if it is null. In other words, if Hibernate fails on creating a session, the code throws a Null Pointer in the catch block and you don't know what the original exception is. The finally block should have a similar null check for session.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Thanks for your reply Jeanne..

Now I'm taking another exception :

org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping clazz="model.Users"/>

Here's my Users class that is generated Hibernate tools..

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Null Pointer Exception @ SessionFactory
 
Similar Threads
Attribute "value" must be declared for element type "property"???
Cannot open connection issue
Getting an exception in Hibernate, was fine till yesterday
Issue in inserting into DB using Hibernate, Spring
Duplicate class/entity mapping error