org.hibernate.QueryException:无法使用where子句解析属性

时间:2017-07-29 08:41:41

标签: java hibernate hql

我试图根据每个客户的状态为" Actve" 的条件在客户数据中获取数据这是插入时的默认值但是我正在设置它在一些查询中被停用,最终我只想要那些有状态" Active"

的人

我这样做了

@Override
    public List<Customer> listCustomers() {

return this.sessionFactory.getCurrentSession().createQuery("from customer).list(); 

}

但我得到所有有效和停用客户

然后我做了这个

@Override
    public List<Customer> listCustomers() {

        return this.sessionFactory.getCurrentSession().createQuery("from com.mphasis.bharathbank.bean.customer where status="+"'Active'").list();
    }

这里我得到了例外

  

SEVERE:servlet [dispatcher]的Servlet.service()与上下文有关   路径[/ BharathBank]抛出异常[请求处理失败;嵌套   异常是org.hibernate.QueryException:无法解析属性:   状态:com.mphasis.bharathbank.bean.Customer [来自   com.mphasis.bharathbank.bean.Customer as c where c.status = Active]]   与根本原因org.hibernate.QueryException:无法解决   property:status of:com.mphasis.bharathbank.bean.Customer [from   com.mphasis.bharathbank.bean.Customer as c where c.status = Active]

模型客户类

@Entity(name="customer")
@Table(name="customer")
public class Customer implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy =GenerationType.AUTO)
    @Column(name="CustID")
    private int CustID;

    @Column(name="Mobile_No")
    private String mobileno;

    @Column(name="F_Name")
    private String fname;

    @Column(name="L_Name")
    private String lname;

    @Column(name="Email_Id")
    private String emailid;

    @Column(name="DOB")
    private String dob;

    @Column(name="Gender")
    private String gender;


    @Column(name="Acc_No")
    private String accno;

    @Column(name="Pwd")
    private String Pwd;


     @Column(name="present_address")
     private String present_address;

     @Column(name="permanent_address")
     private String permanent_address;

     @Column(name="occupation")
     private String occupation;

     @Column(name="marital_status")
     private String marital_status;

     @Column(name="adhaar_card_no")
     private String adhaar_no;

     @Column(name="pan")
     private String pan;

     @Column(name="Balance")
     private String initial_bal;

     @Column(name="status")
     private String accstatus;

    public String getAccstatus() {
        return accstatus;
    }

    public void setAccstatus(String accstatus) {
        this.accstatus = accstatus;
    }


    public int getCustID() {
        return CustID;
    }

    public void setCustID(int custID) {
        CustID = custID;
    }

    public String getMobileno() {
        return mobileno;
    }

    public void setMobileno(String mobileno) {
        this.mobileno = mobileno;
    }

    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public String getLname() {
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public String getEmailid() {
        return emailid;
    }

    public void setEmailid(String emailid) {
        this.emailid = emailid;
    }

    public String getDob() {
        return dob;
    }

    public void setDob(String dob) {
        this.dob = dob;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAccno() {
        return accno;
    }

    public void setAccno(String accno) {
        this.accno = accno;
    }



    public String getPwd() {
        return Pwd;
    }

    public void setPwd(String pwd) {
        Pwd = pwd;
    }

    public String getPresent_address() {
        return present_address;
    }

    public void setPresent_address(String present_address) {
        this.present_address = present_address;
    }

    public String getPermanent_address() {
        return permanent_address;
    }

    public void setPermanent_address(String permanent_address) {
        this.permanent_address = permanent_address;
    }

    public String getOccupation() {
        return occupation;
    }

    public void setOccupation(String occupation) {
        this.occupation = occupation;
    }

    public String getMarital_status() {
        return marital_status;
    }

    public void setMarital_status(String marital_status) {
        this.marital_status = marital_status;
    }



    public String getAdhaar_no() {
        return adhaar_no;
    }

    public void setAdhaar_no(String adhaar_no) {
        this.adhaar_no = adhaar_no;
    }

    public String getPan() {
        return pan;
    }

    public void setPan(String pan) {
        this.pan = pan;
    }

    public String getInitial_bal() {
        return initial_bal;
    }

    public void setInitial_bal(String initial_bal) {
        this.initial_bal = initial_bal;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    }

0 个答案:

没有答案