Mirror<?> mirror = Mirror.me(this.getClass());
Field[] fields = mirror.getFields(CndType.class); //fileds没有filed对象
public class UserQuery extends BaseQuery {
@CndType("=")
private String id;
@CndType("like")
private String name;
@OrderType("asc")
private String updateTime;
@OrderType("desc")
private String createTime;
//......
}
7 回复
public class UserQuery extends BaseQuery {
@CndType("=")
private String id;
@CndType("like")
private String name;
@OrderType("asc")
private String updateTime;
@OrderType("desc")
private String createTime;
Mirror<?> mirror = Mirror.me(this.getClass());
Field[] fields = mirror.getFields(CndType.class); //fileds为空数组
}
public class UserQuery extends BaseQuery {
@CndType("=")
private String id;
@CndType("like")
private String name;
@OrderType("asc")
private String updateTime;
@OrderType("desc")
private String createTime;
public void test(){
Mirror<?> mirror = Mirror.me(this.getClass());
Field[] fields = mirror.getFields(CndType.class); //fileds为空数组
}
}
public class UserQuery extends BaseQuery {
@CndType("=")
private String id;
@CndType("like")
private String name;
@OrderType("asc")
private String updateTime;
@OrderType("desc")
private String createTime;
public void test(){
Mirror<?> mirror = Mirror.me(this.getClass());
Field[] fields = mirror.getFields(CndType.class); //fileds为空数组
}
}
我的测试代码
public class UserQuery {
@Column("=")
private String id;
@Column("like")
private String name;
@Column("asc")
private String updateTime;
@Column("desc")
private String createTime;
@Test
public void test() {
Mirror<?> mirror = Mirror.me(this.getClass());
Field[] fields = mirror.getFields(Column.class); // fileds为空数组
System.out.println(Arrays.toString(fields));
}
}
输出
[private java.lang.String net.wendal.nutzbook.UserQuery.id, private java.lang.String net.wendal.nutzbook.UserQuery.name, private java.lang.String net.wendal.nutzbook.UserQuery.updateTime, private java.lang.String net.wendal.nutzbook.UserQuery.createTime]
@CndType和@OrderType是不是声明错了, 起码要加上这个才能读取的.
@Retention(RetentionPolicy.RUNTIME)
添加回复
请先登陆