如果使用ebean的Type safe queries (Query Beans) 查询方式,ebean会通过enhancement方式通过插件自动生成Q开头的基于编写的entity的query bean
StudentEntity —>生成 QStudentEntity ,做类型检查
query bean的生成位置在
//resources/ebean.mf
querybean-packages: web.entity.query
没有ebean enhence插件, 可能会报错
Bean class web.entity.StudentEntity is not enhanced?
可以自己手动生成query bean
//pom.xml
<dependency>
<groupId>io.ebean.tools</groupId>
<artifactId>finder-generator</artifactId>
<version>4.2.1</version>
</dependency>
需要一个java的类,执行main
import io.ebean.typequery.generator.Generator;
import io.ebean.typequery.generator.GeneratorConfig;
import java.io.IOException;
public class QueryBeanGenerator {
//Manual generate query bean
//first it compile the entity.java to .class then use ASM to generate query bean
//only used for Ebean Type safe queries (Query Beans)
public static void main(String[] args) throws IOException{
GeneratorConfig config = new GeneratorConfig();
//entity package
//path:ebean.mf querybean-packages
config.setEntityBeanPackage("web.entity");
Generator generator = new Generator(config);
generator.generateQueryBeans();
}
}
会在指定位置生成query bean和assoc目录(QAssoc开头的映射文件)