eclipselink batch write is disabled when use history policy or DescriptorEventAdapter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 01:36:20

问题


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.

来源:https://stackoverflow.com/questions/37848686/eclipselink-batch-write-is-disabled-when-use-history-policy-or-descriptoreventad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!