Bulk insert of multiple entities

In one transaction I create and update many rows in many tables. For example, I do something like this:

try (Transaction tx = persistence.createtransaction()) {
    EntityOne entityOne1 = metadata.create(EntityOne.class);
    EntityOne entityOneN = metadata.create(EntityOne.class);
    EntityTwo entityTwo1 = metadata.create(EntityTwo.class);
    EntityOne entityTwoN = metadata.create(EntityTwo.class);


Then I enable eclipselink.sql in logs and see multiple inserts by one row, like
insert into entity_one (k1, …, kn) values (…)
insert into entity_one (k1, …, kn) values (…)
Is it just logs, or there are really multiple inserts into one table? Can I somehow enable bulk insert?
java 11, cuba version - 7.0
Thank you!

1 Like


Batch writing is not enabled by default.
Try to add the following properties to your app.properties:

eclipselink.jdbc.batch-writing = jdbc
eclipselink.jdbc.batch-writing.size = 1000

See EclipseLink docs.

@knstvk, thank you!