mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#869 - Test for ... Clash on bind hash value for query cache with consecutive values of "01","20" and "02", "10"
This commit is contained in:
@@ -2,6 +2,7 @@ package com.avaje.tests.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.tests.model.cache.EColAB;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -12,8 +13,41 @@ import com.avaje.ebean.cache.ServerCache;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestQueryCache extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void clashHashCode() {
|
||||
|
||||
new EColAB("01", "20").save();
|
||||
new EColAB("02", "10").save();
|
||||
|
||||
List<EColAB> list1 =
|
||||
Ebean.getServer(null)
|
||||
.find(EColAB.class)
|
||||
.setUseQueryCache(true)
|
||||
.where()
|
||||
.eq("columnA", "01")
|
||||
.eq("columnB", "20")
|
||||
.findList();
|
||||
|
||||
List<EColAB> list2 =
|
||||
Ebean.getServer(null)
|
||||
.find(EColAB.class)
|
||||
.setUseQueryCache(true)
|
||||
.where()
|
||||
.eq("columnA", "02")
|
||||
.eq("columnB", "10")
|
||||
.findList();
|
||||
|
||||
assertThat(list1.get(0).getColumnA()).isEqualTo("01");
|
||||
assertThat(list1.get(0).getColumnB()).isEqualTo("20");
|
||||
|
||||
assertThat(list2.get(0).getColumnA()).isEqualTo("02");
|
||||
assertThat(list2.get(0).getColumnB()).isEqualTo("10");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test() {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.avaje.tests.model.cache;
|
||||
|
||||
import com.avaje.ebean.Model;
|
||||
import com.avaje.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Cache(enableQueryCache=true)
|
||||
@Entity
|
||||
@Table(name = "e_col_ab")
|
||||
public class EColAB extends Model {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String columnA;
|
||||
|
||||
private String columnB;
|
||||
|
||||
public EColAB(String columnA, String columnB) {
|
||||
this.columnA = columnA;
|
||||
this.columnB = columnB;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getColumnA() {
|
||||
return columnA;
|
||||
}
|
||||
|
||||
public void setColumnA(String columnA) {
|
||||
this.columnA = columnA;
|
||||
}
|
||||
|
||||
public String getColumnB() {
|
||||
return columnB;
|
||||
}
|
||||
|
||||
public void setColumnB(String columnB) {
|
||||
this.columnB = columnB;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user