Play!框架中GenericModel.findAll的实现在哪里?

时间:2013-01-12 07:49:03

标签: playframework

我只看到这个:

     /**
     * Find all entities of this type
     */
    public static <T extends JPABase> List<T> findAll() {
        throw new UnsupportedOperationException("Please annotate your JPA model with @javax.persistence.Entity annotation.");
    }

它的实施在哪里?我的意思是,我放置了哪些SQL序列?

1 个答案:

答案 0 :(得分:0)

此代码在JPAEnhancer类中定义,该类适用于所有JPA实体:

public class JPAEnhancer extends Enhancer {

    public void enhanceThisClass(ApplicationClass applicationClass) throws Exception {
        CtClass ctClass = makeClass(applicationClass);
     ...
        // findAll
        CtMethod findAll = CtMethod.make("public static java.util.List findAll() { return play.db.jpa.JPQL.instance.findAll(\"" + entityName + "\"); }", ctClass);
        ctClass.addMethod(findAll);
    ... 
}