Hello there,
I have a question about how does JPA handle changes in tables made by
database triggers or other JDBC connections (from within the same EJB
module of course).
If I change database record using JDBC and then I invoke
em.find(Something.class, someID), will TopLink figure out that
something changed? Or will I get stale data?
If I use @Version fields, are they going to help? For example, JPA
could check if version changed and reload entity automatically.
I am asking, because I have application that is using JPA, but JPA is
really bad for massive data modifications. In my case, I have few
services like the one that has to update about 20.000 records -
calculation of interest on every active loan. The result of that will
create Transaction entities, AccountEntry entities, it has to update
loan's checkDate/status property generate proper Actions, check
Actions generated before to insert or update Tasks...etc...)
With JDBC, very similar operations can be done in seconds, but using
JPA that would last for ever because of thousands of separate selects,
huge memory footprint...
I am just worried, if I implement this using DataSource bypassing
EntityManager, will I desynchronize EM cache with database? That would
lead to disaster :/
Thanks,
Witold Szczerba