I try to use eclipselink history policy to record the change history of one table/entity. I also use DescriptorEventAdapter/aboutToInsert,aboutToUpdate,aboutToDelete hooks to insert audit record. All things works well except that I found the batch-writing option did not work after I apply the features above.
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
The code is like:
for (int i = 0; i <= 3; i++) {
MyEntity e= new MyEntity ();
e.setName("insert-" + i);
entityManager.save(e);
}
When I disable history/DescriptorEventAdapter, the sql is like:
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY (ID, NAME) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [1, insert-0]
DEBUG o.e.p.s./.sql - bind => [2, insert-1]
DEBUG o.e.p.s./.sql - bind => [3, insert-2]
DEBUG o.e.p.s./.sql - bind => [4, insert-3]
After apply the history/DescriptorEventAdapter
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY (ID, NAME) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [1, insert-0]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY_HIST (ID, NAME, VALID_FROM) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [1, insert-0, 2016-06-16 01:55:22.424]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY (ID, NAME) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [2, insert-1]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY_HIST (ID, NAME, VALID_FROM) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [2, insert-1, 2016-06-16 01:55:22.424]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY (ID, NAME) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [3, insert-3]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY_HIST (ID, NAME, VALID_FROM) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [3, insert-3, 2016-06-16 01:55:22.424]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY (ID, NAME) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [4, insert-3]
DEBUG o.e.p.s./.sql - INSERT INTO MY_ENTITY_HIST (ID, NAME, VALID_FROM) VALUES (?, ?)
DEBUG o.e.p.s./.sql - bind => [4, insert-3, 2016-06-16 01:55:22.424]
Could you please give some suggestion this? Thanks in advance.