通过在Play中使用ebean,我遇到了Finder对象的select函数的问题!框架(2.2.1)。
我的桌子是AnneePromotion:
CREATE TABLE AnneePromotion (
anneePromotion_ID INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('AnneePromotionSequence'),
anneePromotion_libelle INTEGER NOT NULL
);
我的实体AnneePromotion:
@Entity
@Table(name = "AnneePromotion")
@SequenceGenerator(name = "AnneePromotionSequenceGenerator", sequenceName = "AnneePromotionSequence")
public class AnneePromotion extends Model {
/** serial ID */
private static final long serialVersionUID = -2072489268439045171L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AnneePromotionSequenceGenerator")
@Column(name = "anneePromotion_ID")
private Integer id;
@Column(name = "anneePromotion_libelle")
private String libelle;
public Integer getId() {
return id;
}
public String getLibelle() {
return libelle;
}
public void setLibelle(String libelle) {
this.libelle = libelle;
}
public static Finder<Integer, AnneePromotion> find = new Finder<Integer, AnneePromotion>(
Integer.class, AnneePromotion.class);
}
当我尝试使用select函数才能拥有libelle:
List<AnneePromotion> listeDesAnneesdePromotion = AnneePromotionDao.find
.select("libelle").orderBy("libelle asc").findList();
for (AnneePromotion anneepromotion : listeDesAnneesdePromotion){
System.out.println(anneepromotion.getId()+" "+anneepromotion.getLibelle());
}
我收到了id和libelle列的对象:
1 2003
2 2004
3 2005
4 2006
5 2007
6 2008
7 2009
8 2010
9 2011
10 2012
11 2013
12 2014
13 2015
14 2016
我不知道select函数不起作用,如果我犯了一个愚蠢的错误:/
希望你能帮助我。
问候,安东尼。
答案 0 :(得分:1)