I've been testing out the JPA for a coule of weeks or so. I'm using Netbeans 6 (Java SE - creating desktop apps) and SQL server. I've got CRUD stuff working on some basic tables I created, no probs - and generally I really like the idea of using this in future apps. I then decided to hook up to the Northwind database and try it out on a couple of the tables.
I picked the 'categories' table and got the entity class created etc. On trying to insert a new record I got the following:
javax.persistence.RollbackException: java.lang.NullPointerException
I spent hours going through this trying to find my error. I created a new table and gradually built up the same structure as the Categories table - adding a column at a time. Eventually, I discovered that if I removed the @Lob annotation from the Description column (ntext) and the Picture column (image) then the insert works fine. If I put it back I get the error.
Of course, I MAY be doing something else wrong - but I think it's something to do with the JPA. We turned on the profiler on SQL Server and the insert statement wasn't even hitting the database.
I'm wondering what the consequences are of leaving the @Lob annotation off for datatypes like ntext, image etc? Has anyone else had this problem?
The code I'm using to test an insert into the Categories table is as follows.
(The entitymanager is a protected field within the same class)
public void testCategories()
{
CategoryService cs = new CategoryService(em);
try{
this.em.getTransaction().begin();
Categories cat = cs.createCategory("Sewing");
this.em.getTransaction().commit();
System.out.println(cat.getCategoryID());
}
catch(javax.persistence.RollbackException ex)
{
System.out.println(ex.toString());
}
}
[Message sent by forum member 'sprite64' (sprite64)]
http://forums.java.net/jive/thread.jspa?messageID=245002