File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes persist() null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "persist() null pointer exception" Watch "persist() null pointer exception" New topic

persist() null pointer exception

Alan Smith
Ranch Hand

Joined: Oct 19, 2011
Posts: 185


I have yet been able to insert a record into a table using the Entitymanager. Everytime I use the persist method I get a null pointer exception. I have a person entity with id(auto incrememted), name, job, salary,description, countyId(foreign key) in a MySql table call Person. My servlet creates a Manager class and passes in parameters submitted representing Person information.

The manager class looks like this:

The PersonFacade class i am using is a netbeans generated session bean:

and AbstractFacade is as follows:

edit: Person entity class

I can read person entries from the database using the personFacades findAll() method but I can't write to it using the create() method without a null pointer exception showing up. All the objects I use are not pointing to a null reference so I can't get my head around it! I have seen examples all over the net that use the persist method. Could someone please help?

James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Please include the exception stack trace.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
I agree. Here's the link:
subject: persist() null pointer exception
jQuery in Action, 3rd edition