【发布时间】:2014-06-02 02:49:23
【问题描述】:
我是 HQL 新手,我需要有关此错误的帮助。
查询:
String hqlsearchSelect =
"select new com.eteligent.core.loans.paging.LoansAppCustomerPageItem("
+ "main.loanno, (SELECT acct.id.clientid FROM LMSAccountInfo acct WHERE acct.loanno = main.loanno), (SELECT acct.name FROM LMSAccountInfo acct WHERE acct.loanno = main.loanno), main.acctsts, "
+ "main.loanbal, (SELECT acct.matdt FROM LMSAccountInfo acct WHERE acct.loanno = main.loanno) )";
我认为查询无法确定它将返回哪条记录。
构造函数(LoansAppCustomerPageItem):
public LoansAppCustomerPageItem( final String acctNo, final String cifNo, final String customerName, final Integer acctStat, final BigDecimal acctBal, final Date acctDueDate )
{
super();
this.acctNo = acctNo;
this.cifNo = cifNo;
this.customerName = customerName;
this.acctStat = acctStat;
this.acctBal = acctBal;
this.acctDueDate = acctDueDate;
}
【问题讨论】:
-
关系映射是否正确?关系都是一对一的吗? LoansAppCustomerPageItem 类的构造函数是什么样的?
-
这两个表之间没有关系,这就是我使用子查询的原因。我已经编辑了上面的帖子以包含构造函数。
-
HQL 不是这项工作的好工具。它旨在与映射实体一起使用。