users@glassfish.java.net

Re: JPA + database triggers or other non-JPA db manipulation

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 15 Oct 2007 14:43:49 -0700

Hi Witold,

Please be aware of the issue
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3334 when em.find()
executed before any update in this EM, can't see an entity inserted by JDBC in
the same transaction.

Regards,
-marina

Witold Szczerba wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>