mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-06 14:15:50 +08:00
fix: 修复QueryHelper查询时无法使用父类字段
This commit is contained in:
@@ -37,6 +37,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -44,6 +45,7 @@ import reactor.util.context.Context;
|
||||
import reactor.util.context.ContextView;
|
||||
|
||||
import javax.persistence.Table;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
@@ -318,7 +320,11 @@ public class DefaultQueryHelper implements QueryHelper {
|
||||
this.tableType = tableType;
|
||||
this.targetProperty = setter == null ? null : MethodReferenceConverter.convertToColumn(setter);
|
||||
if (this.targetProperty != null) {
|
||||
propertyType = ResolvableType.forField(parent.clazz.getDeclaredField(targetProperty), parent.clazz);
|
||||
Field field = ReflectionUtils.findField(parent.clazz, targetProperty);
|
||||
if (field == null) {
|
||||
throw new NoSuchFieldException(parent.clazz.getName() + "." + targetProperty);
|
||||
}
|
||||
propertyType = ResolvableType.forField(field, parent.clazz);
|
||||
} else {
|
||||
propertyType = null;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class DefaultQueryHelperTest {
|
||||
.insert("s_test")
|
||||
.value("id", "inner-test")
|
||||
.value("name", "inner")
|
||||
.value("testName","inner")
|
||||
.value("testName", "inner")
|
||||
.value("age", 31)
|
||||
.execute()
|
||||
.sync();
|
||||
@@ -159,7 +159,7 @@ class DefaultQueryHelperTest {
|
||||
public void testCustomFirstPageIndex() {
|
||||
DefaultQueryHelper helper = new DefaultQueryHelper(database);
|
||||
QueryParamEntity e = new QueryParamEntity();
|
||||
e.and("id","eq","testCustomFirstPageIndex");
|
||||
e.and("id", "eq", "testCustomFirstPageIndex");
|
||||
e.setFirstPageIndex(1);
|
||||
e.setPageIndex(2);
|
||||
|
||||
@@ -243,7 +243,7 @@ class DefaultQueryHelperTest {
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public static class TestInfo {
|
||||
public static class TestInfo extends TestInfoSuper {
|
||||
|
||||
private String id;
|
||||
|
||||
@@ -255,6 +255,11 @@ class DefaultQueryHelperTest {
|
||||
|
||||
private EventTestEntity event;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class TestInfoSuper {
|
||||
private List<EventTestEntity> eventList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user