Hi there I am complete newbie to JPA. I am trying to select a particular set of records using one column as the criteria. My entity code was auto generated based on the table structure as follows:
create table TEST.COMPUTERS(
"COLUMN1" VARCHAR2(6) not null,
"COLUMN2" VARCHAR2(10) not null,
"COLUMN3" VARCHAR2(5) not null,
"COLUMN4" VARCHAR2(8) not null,
"COLUMN5" VARCHAR2(48),
constraint "PK" primary key ("COLUMN1","COLUMN2")
);
班级教员法:
@Table(name = "COMPUTERS", schema = "TEST")
public class Computers implements java.io.Serializable {
/** full constructor */
public Computers(ComputersId id, String column3, String column4,
String column5) {
this.id = id;
this.column3 = column3;
this.column4 = column4;
this.column5 = column5;
}
@EmbeddedId
public ComputersId getId() {
return this.id;
}
public void setId(ComputersId id) {
this.id = id;
}
// and then ....getter and setter methods for Column 3-5
然后我做如下工作:
Query query = EntityManagerHelper.getEntityManager().createQuery("SELECT s from Computers s where s.column1 = :column1").setParameter("column1", "SONY LAPTOPS");
上面一行,我有以下错误:
An error occurred while parsing the query filter "SELECT s from Computers where s.column1 = :column1". Error message: No field named "column1" in class "class Computers".
任何要点? 许多人表示感谢。