ObjectDB ObjectDB

how to operate with same object but two different Thread on database.

#1

Hi,

   i have two thread one is for insert data another is for update data but in same object and same database.

Description:

i have three classes 

GetterSetterclass.java

here declare variables and Getter and setter method constructor and to-string method.

Insert.java 

Here i create a thread, create object of Gettersettetclass, i.e insert operation and pass that object to update.java class.

Update.java

Here i want create another thread define a method which is for update operation. and i am getting that object here  which is passes from insert.java class.Then here i want to do update operation with that same object and same database.

---------

So, point is two different operation, two different thread,one object(we can assume one table in sql), one database.

if it will possible, then what is the procedure.

if you want to see my code it is attach below,please see it once.

Thank you.

edit
delete
#2

Usually multithreading with JPA involves multiple EntityManager instances, one per thread. Every thread with its own EntityManager has a private persistence context, i.e. the same database object is represented by multiple separate memory objects in different entity managers and threads. Locks are used to avoid conflict in updating the same object as the same time.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.