mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-22 02:26:08 +00:00
perf[module]: orm的map的key必须是String,value没要求
This commit is contained in:
@@ -512,7 +512,7 @@ public class OrmManager implements IOrmManager {
|
||||
var valueType = types[1];
|
||||
|
||||
if (!String.class.isAssignableFrom((Class<?>) keyType)) {
|
||||
throw new RunException("ORM中Map的key必须是String类型");
|
||||
throw new RunException("ORM[class:{}]类型声明不正确,Map的key类型必须为String类型", clazz.getCanonicalName());
|
||||
}
|
||||
|
||||
checkSubEntity(clazz, valueType);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Ignore
|
||||
public class MapTest {
|
||||
@@ -55,6 +56,10 @@ public class MapTest {
|
||||
bagMap.put("bag2", bagItem2);
|
||||
bagMap.put("bag3", bagItem3);
|
||||
|
||||
var map = new HashMap<String, Map<String, String>>();
|
||||
map.put("a", Map.of("b", "b"));
|
||||
entity.setBaseMap(map);
|
||||
|
||||
OrmContext.getAccessor().insert(entity);
|
||||
|
||||
var myEntity = OrmContext.getAccessor().load(1, MapEntity.class);
|
||||
|
||||
@@ -29,6 +29,8 @@ public class MapEntity implements IEntity<Long> {
|
||||
|
||||
private Map<String, BagItem> bagMap = new HashMap<>();
|
||||
|
||||
private Map<String, Map<String, String>> baseMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Long id() {
|
||||
return id;
|
||||
@@ -50,6 +52,13 @@ public class MapEntity implements IEntity<Long> {
|
||||
this.bagMap = bagMap;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getBaseMap() {
|
||||
return baseMap;
|
||||
}
|
||||
|
||||
public void setBaseMap(Map<String, Map<String, String>> baseMap) {
|
||||
this.baseMap = baseMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
Reference in New Issue
Block a user