#1864 - L2 cache miss for natural key property of type UUID

This commit is contained in:
rob bygrave
2019-11-17 17:06:38 +13:00
parent 9b0dd2b0c4
commit c2a30f786f
6 changed files with 122 additions and 14 deletions
@@ -8,7 +8,7 @@ public interface NaturalKeyEntry {
/**
* Return the natural cache key (String concatenation of values).
*/
Object key();
String key();
/**
* Return the inValue (used to remove from IN clause of original query).
@@ -14,7 +14,7 @@ import java.util.Map;
class NaturalKeyEntryBasic implements NaturalKeyEntry {
private final Map<String,Object> map = new HashMap<>();
private final Object key;
private final String key;
private Object inValue;
/**
@@ -57,12 +57,12 @@ class NaturalKeyEntryBasic implements NaturalKeyEntry {
}
}
private Object calculateKey(BeanNaturalKey naturalKey) {
private String calculateKey(BeanNaturalKey naturalKey) {
return naturalKey.calculateKey(map);
}
@Override
public Object key() {
public String key() {
return key;
}
@@ -2,19 +2,21 @@ package io.ebeaninternal.api;
class NaturalKeyEntrySimple implements NaturalKeyEntry {
private final Object key;
private final String key;
private final Object val;
NaturalKeyEntrySimple(Object key) {
this.key = key;
NaturalKeyEntrySimple(Object val) {
this.key = val.toString();
this.val = val;
}
@Override
public Object key() {
public String key() {
return key;
}
@Override
public Object getInValue() {
return key;
return val;
}
}
@@ -66,11 +66,7 @@ public class BeanNaturalKey {
*
* @param map The bind values for the properties.
*/
public Object calculateKey(Map<String, Object> map) {
if (naturalKey.length == 1) {
return map.get(naturalKey[0]);
}
public String calculateKey(Map<String, Object> map) {
StringBuilder sb = new StringBuilder();
for (BeanProperty prop : props) {
sb.append(prop.naturalKeyVal(map)).append(";");