我只想获取具有特定 ID 的数据。我的包含查询的方法是:
public static List getidProducts(Integer id) {
List<Products> productsid = Products.find("product_id IN:id").bind("id", id).fetch();
return productsid;
}
我收到错误:未找到符号,它表明错误出现在方法find()中。我哪里错了?请建议我。
这是我的 products.java
package models;
import java.util.*;
import javax.persistence.*;
import play.db.ebean.*;
import play.data.format.*;
import play.data.validation.*;
import com.avaje.ebean.*;
import java.sql.*;
public class Products extends Model {
@Id
public Integer product_id;
@Constraints.Required
public String productname;
@Constraints.Required
public Integer quantity;
@Constraints.Required
public Integer price;
public static Finder<Integer,Products> find = new Finder<Integer,Products>(Integer.class, Products.class);
public static List getidProducts(Integer id) {
return Products.find().where().in("id", id).findList();
}
}