Fix EmbeddedId not found cache (#1811)

This commit is contained in:
Rien
2019-09-11 22:06:05 +12:00
committed by Rob Bygrave
parent ac6db11e3d
commit faba55d772
+32
View File
@@ -0,0 +1,32 @@
package org.tests.cache;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.Test;
import org.tests.model.basic.CKeyParent;
import org.tests.model.basic.CKeyParentId;
import static org.junit.Assert.assertNotNull;
public class TestCacheEmbeddedId extends BaseTestCase {
@Test
public void test() {
CKeyParentId id = new CKeyParentId(100, "testEmbedded");
CKeyParent p = new CKeyParent();
p.setId(id);
p.setName("testCache");
DB.save(p);
CKeyParent cKeyParent = DB.find(CKeyParent.class, id);
assertNotNull(cKeyParent);
// find for second time
// causes java.lang.ClassCastException: class java.lang.String cannot be cast to class org.tests.model.basic.CKeyParentId
cKeyParent = DB.find(CKeyParent.class, id);
assertNotNull(cKeyParent);
}
}