String sql="select new com.gehua.InfoSystem.pojo.CPayRecord_CFix(cp.id,cp.yhId,cp.beizhu,cp.PTimestamp,cp.PZhuantai,cp.macaddress,cp.churen,cp.chushi,cf.azCmMac) from CPayRecord as cp ,CFix as cf where cp.yhId=cf.yhId";
??类CPayRecord_CFix
public class CPayRecord_CFix { private Integer id;
private String yhId;
private String beizhu;
private Date PTimestamp;
private String PZhuantai;
private String macaddress;
private String churen;
private String chushi;
private String azCmMac;

public CPayRecord_CFix(){

} public CPayRecord_CFix(
Integer id, 
String yhId, String beizhu,
Date PTimestamp,String PZhuantai, 
String macaddress, String churen,
String chushi
, String azCmMac
) {

this.id = id;
this.yhId = yhId;
this.beizhu = beizhu;
this.PTimestamp = PTimestamp;
this.PZhuantai = PZhuantai;
this.macaddress = macaddress;
this.churen = churen;
this.chushi = chushi;
this.azCmMac = azCmMac;
}
...get(),set()方法...
为何老是报
Cause:
org.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.gehua.InfoSystem.pojo.CPayRecord_CFix

解决方案 »

  1.   

    no appropriate constructor in class: com.gehua.InfoSystem.pojo.CPayRecord_CFix//Maybe you should check up if  parameter list  of  CPayRecord_CFix object created by you  matches with constructor's parameters.
      

  2.   

     from CPayRecord as cp
    你有这个CPayRecord 类吗?
      

  3.   

    为com.gehua.InfoSystem.pojo.CPayRecord_CFix类加一个不带参数的构造函数
      

  4.   

    我有这个类CPayRecord ,CFix这两个bean是hibernate自动生成的(这两个表没有外键或主键关联,但都有yhId字段),但是我只想取两个表其中的某些字段
      

  5.   


    select new com.gehua.InfoSystem.pojo.CPayRecord_CFix(cp.id,cp.yhId,cp.beizhu,cp.PTimestamp,cp.PZhuantai,cp.macaddress,cp.churen,cp.chushi,cf.azCmMac) from CPayRecord as cp ,CFix as cf where cp.yhId=cf.yhId";
    这里的参数顺序和构造函数的参数顺序是一样的啊,但是我测试了一下只查一个表的时候就不报错