Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Serious error in JPA with @Version

Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to use JPA entity class to insert and update records in to Java Durby Database and i am using @Version.

I m using NetBeans 6.1,Java Durby as a database

following is my table in database :

create table STUDENT
RNO int primary key,
FNAME varchar(20) ,
LNAME varchar(20),
M1 int,
M2 int,
AVEG double,
RES varchar(20),

Following is my Entity calass :

I am using Oracle Toplink as Persistance Provider :

Following is my Persistance Unit's persistence.xml file :

Following is a Client code i am using to Insert a Record :

The above code works completely fine and it inserts a record in to database with VERSION = 1

but wen i try to update the same record by following code i m getting an error :
Update code :

when i run the above program i ger following error in output window :

While updating the version should become 2 but instead i get the above error.

I m getting the same problem while using the same entity class in EJB also with glassfish server & Durby DB
I have no idea from where this java.lang.NullPointerException is coming from

IF I REMOVE @Version FROM ENTITY CLASS THE CODE WORKS FINE it then updates the record.

please let me know if i have made any mistakes .


Hug your destiny! And hug this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic