aspose file tools*
The moose likes Object Relational Mapping and the fly likes Serious error in JPA with @Version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Serious error in JPA with @Version" Watch "Serious error in JPA with @Version" New topic
Author

Serious error in JPA with @Version

Dhiren Lodhia
Greenhorn

Joined: Mar 05, 2008
Posts: 14
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),
VERSION int
)

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 .

Thanks


Dhiren Lodhia
SCJP 5.0 (93%)
 
Consider Paul's rocket mass heater.
 
subject: Serious error in JPA with @Version