0
由于EclipseLink中的更改跟踪,我们目前在我们的应用程序中经历了严重的减速。这个问题是自制的,我们不按照它的意图使用JPA。EclipseLink禁用每个查询的更改跟踪
我想知道,我如何获得缓存命中(第1级),但不包括这些实体在更改跟踪中,除非满足某些条件。
// not real code, but close if you decompose the layers and inline methods
public void foo(Long customerId, boolean changeName, String newName) {
/*** check customer valid ***/
// #1 HOW TO discard from change tracking? – Customer won’t get modified!
Customer customer = entityManager.find(Customer.class, customerId);
// some Business Rules
// #2 They should be auto discarded from change tracking because #1 is also discarded)
checkSomething(customer.getAddresses());
checkSomething(customer.getPhoneNumbers());
…
/*** manipulate customer ***/
// somewhere else in different classes/methods …
if(changeName) {
// #3 HOW TO get Cache hit (1st level) - it was read in #1
// newName should be persisted
customer = entityManager.find(Customer.class, customerId);
customer.setName(newName);
}
}
这将是确定使用的EclipseLink API的#1和#2
我宁愿提示。
的EclipseLink 2.4.2
二级缓存:禁用
ChangeTrackingType:递延
感谢您的回答。不幸的是,我们不使用二级缓存(会话缓存)。 使用只读提示可防止在步骤#3中对这些实体进行更改 - 因此这也不起作用。 –
在初始查找操作之后,您将不得不考虑复制您的实体 – Chris