#115 - Mapping - Add support for @ElementCollection enhancement

Add element collection L2 cache support
This commit is contained in:
Rob Bygrave committed 2018-03-29 01:15:58 +13:00
1 parent 07946cd505
commit acd5578d8a
52 files changed
+734 -135

No files matched your search

@@ -6,12 +6,18 @@ import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* Base for saving entity bean collections and element collections.
*/
abstract class SaveManyBase {
private static final Logger log = LoggerFactory.getLogger(SaveManyBase.class);
final PersistRequestBean<?> request;
final SpiEbeanServer server;
final boolean insertedParent;
@@ -48,4 +54,17 @@ abstract class SaveManyBase {
}
c.modifyReset();
}
void postElementCollectionUpdate() {
if (!insertedParent) {
if (request.postElementCollectionUpdate()) {
try {
String asJson = many.jsonWriteCollection(value);
request.addCollectionChange(many.getName(), asJson);
} catch (IOException e) {
log.error("Error build element collection entry for L2 cache", e);
}
}
}
}
}
@@ -49,8 +49,6 @@ class SaveManyElementCollection extends SaveManyBase {
transaction.depth(-1);
resetModifyState();
if (!insertedParent) {
request.postElementCollectionUpdate();
}
postElementCollectionUpdate();
}
}
@@ -50,8 +50,6 @@ class SaveManyElementCollectionMap extends SaveManyBase {
transaction.depth(-1);
resetModifyState();
if (!insertedParent) {
request.postElementCollectionUpdate();
}
postElementCollectionUpdate();
}
}