mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
JSON bean dirty detection via MD5 of JSON string content
- MD5 of json content stored on EntityBeanIntercept for dirty detection - Only convert to JSON once (at dirty detection time). Store this json content on EntityBeanIntercept to later push to ScalarTypeJsonObjectMapper for bind Should consider alternative to extend BeanProperty rather than have these if blocks.
This commit is contained in:
@@ -91,6 +91,17 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
private Object ownerId;
|
||||
private int sortOrder;
|
||||
|
||||
/**
|
||||
* Holds MD5 hash of json loaded jackson beans.
|
||||
*/
|
||||
private String[] mutableHash;
|
||||
|
||||
/**
|
||||
* Holds json content determined at point of dirty check.
|
||||
* Stored here on dirty check such that we only convert to json once.
|
||||
*/
|
||||
private String[] mutableContent;
|
||||
|
||||
/**
|
||||
* Create a intercept with a given entity.
|
||||
*/
|
||||
@@ -1138,4 +1149,26 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String mutableHash(int propertyIndex) {
|
||||
return mutableHash == null ? null : mutableHash[propertyIndex];
|
||||
}
|
||||
|
||||
public void mutableHash(int propertyIndex, String content) {
|
||||
if (mutableHash == null) {
|
||||
mutableHash = new String[flags.length];
|
||||
}
|
||||
mutableHash[propertyIndex] = content;
|
||||
}
|
||||
|
||||
public String mutableContent(int propertyIndex) {
|
||||
return mutableContent == null ? null : mutableContent[propertyIndex];
|
||||
}
|
||||
|
||||
public void mutableContent(int propertyIndex, String content) {
|
||||
if (mutableContent == null) {
|
||||
mutableContent = new String[flags.length];
|
||||
}
|
||||
mutableContent[propertyIndex] = content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user