mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1864 - L2 cache miss for natural key property of type UUID
This commit is contained in:
@@ -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(";");
|
||||
|
||||
Reference in New Issue
Block a user