users@glassfish.java.net

Re: BULK INSERTS EJB3

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Wed, 5 Nov 2008 16:49:40 +0100

2008/11/5 Dennis Gesker <dennis_at_gesker.com>:
> My experience has also been that JDBC is better for inserting bulk data.
>
> However, the draw back seems to be that when the rest of the application is
> using JPA (for instance for handing data from the database to JSF for
> reporting) JPA remains unaware of the new data in the tables.
>
> Dennis

There are other issues as well, for example:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3866
but this one can be worked around.

Another good idea is to disable level2 cache or clear cache for
specific entities by class and/or id or entire cache after JDBC
operations (for example A owns collection of B, then after inserting B
using JDBC it is wise to clear cache of A-class instances).
It is very important not to forget to flush entity manager before
using JDBC if JPA was used before JDBC operations.

Regards,
Witold Szczerba