My problem is my program don't read the record of a table modified from a external program.
My scenario is:
1. I use a table in AS400/DB2 <br/>
| TNOTA | TCOEL | TCOMM |<br/>
| AGG | 000 | 123 |<br/> table there is '123' in field of record;
2. start the my program, it execute a infinite while, every 30 seconds call function funTable0f();
3. at first loop, after the execution of funTable0f() the value change from '123' to 'XYZ';
4. update the record with a sql command (non with the my program) sql; update tabel0f set tcomm = 'ABC' where tnota = 'AGG and tcoel = '000';
5. at second loop, at "SECOND breackpoint", the object show me the old value 'XYZ' and not 'ABC';
6. always at second loop, at "THIRD brackpoint", the value in table remain 'ABC' and not update with 'XYZ' (hiberante remember the value is just 'XYZ' and not apply the update?)
seems it work with a copy in memory cache of table0f and not with a real table of my as400 table.
class primary key:
class model table0f:
entity manager factory:
I hope I was clear,<br/>
thanks in advance,<br/>
You were a little too "clear", actually. Please don't bury us in code, people will just skip over it.
As I am doing for the moment. I'll just attempt to answer the simple question.
You are mostly correct. In the default JPA setup, if another process modifies a record, your app will not automatically detect the modification. In fact, SQL does not "push" modification notifications, so it wouldn't even be possible to notify your app.
On the other hand, if you changed data in that record and attempted to commit it to the database using standard transaction rules, the commit would fail with a ConcurrentModificationException, as JPA will check the database current record against what it last saw as the database current record when it was fetched.
You may need to use an XA transaction management system in such cases. Or at least catch the ConcurrentModificationException and notify the higher layers of code that the change failed and may need to be re-thought based on the external udates.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.