English 中文(简体)
JPA 1.2 创立 条款标准
原标题:JPA 1.2 createQuery Where Clause Criteria

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".

任何要点? 许多人表示感谢。

最佳回答

由于Column1是被贪污的一部分 you:

Query query  =   EntityManagerHelper.getEntityManager().createQuery("SELECT s from Computers s where s.id.column1 = :column1").setParameter("column1", "SONY LAPTOPS");

PS:你的栏目似乎选择不好的名字? 也许你应该给他们更多的描述性名称?

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签