Java EBeans在JPA中查找()的替代方案

Java EBeans在JPA中查找()的替代方案,java,playframework,ebean,Java,Playframework,Ebean,我在看戏!创建博客的框架教程。它们使用JPA而不是Ebean,并且使用从play.db.JPA.Model扩展而来的find()函数。我使用的是ebean,并通过play.db.ebean.Model进行了扩展。但是,当我使用find()函数时,它表示不存在这样的方法。我做了一些研究,并查看了以下内容: 在这里: 但是没有提到一个简单的find()方法(还有其他方法,比如findId(),但我不知道它们有什么帮助)。我可以在模型课上使用其他方法吗?如果没有,还有其他我可以轻松使用的类吗 编辑:

我在看戏!创建博客的框架教程。它们使用JPA而不是Ebean,并且使用从play.db.JPA.Model扩展而来的find()函数。我使用的是ebean,并通过play.db.ebean.Model进行了扩展。但是,当我使用find()函数时,它表示不存在这样的方法。我做了一些研究,并查看了以下内容:

在这里:

但是没有提到一个简单的find()方法(还有其他方法,比如findId(),但我不知道它们有什么帮助)。我可以在模型课上使用其他方法吗?如果没有,还有其他我可以轻松使用的类吗

编辑:

我需要创建的特定部分是User类中的connect()方法。在本教程中,这被描述为:

In the User.java source, add the connect() method:

public static User connect(String email, String password) {
return find("byEmailAndPassword", email, password).first();
}

如果我不能使用find(),我还有什么其他选项。ebean.find()有效吗?

我知道有两种方法可以使用play.db.ebean.Model的find()方法。 第一个是这样的:

User user = Ebean.find(User.class, id);
//define a Model.finder class in the User model class
 //The first parameter would be the datatype of the id used, which is String in my case
public static Model.Finder<String,User> find = new Model.Finder<String,User>(String.class, User.class);
User user = User.find.byId(id);
User.find.where()
            .eq("email", email).eq("password",password)
            .findUnique();
第二种方法是这样的:

User user = Ebean.find(User.class, id);
//define a Model.finder class in the User model class
 //The first parameter would be the datatype of the id used, which is String in my case
public static Model.Finder<String,User> find = new Model.Finder<String,User>(String.class, User.class);
User user = User.find.byId(id);
User.find.where()
            .eq("email", email).eq("password",password)
            .findUnique();

你用的是什么版本的剧本?这听起来像是你在寻找游戏1.2.x。在Play 2.3.x中不再有JPA模型超类。以“使用play.db.Ebean.Model超类”下的Ebean查询为例。有关更多信息,请参见是的,我使用的是2.2.x。我试图松散地遵循教程,但用EBeans替换JPA。看起来就像我说的,你必须使用find.byId或者类似的东西。您提到的教程中我需要查找()的部分我可以使用什么?谢谢。嗯,我一直在看链接文档中的“Ebean.find”。我能用这个吗?这些示例都是用于查找订单(?),而我在“bean.find”的其他地方找不到太多信息。
Ebean.find()
提供了一个流畅的API,用于实用地构建查询。但是,如果您正在寻找一种更类似SQL的方法,那么也可以传入查询字符串。看看这两个例子。如果你在你的问题中添加更具体的你想做的事情,我可以用例子等来帮助你。我正在添加具体的案例。