我有一个命名查询(简化了一点[删除了一些日期过滤器],以便第一眼就更清楚):
@Entity
@XmlRootElement
@AdditionalCriteria("this.deleted <> 'deleted'")
@NamedQueries({
@NamedQuery(name = "FacilityForm.findByDateFacility", query = "SELECT f FROM FacilityForm f WHERE f.formDate BETWEEN :from and :to AND f.id In (SELECT o.id from InventoryLog l, FormItem i, FacilityForm o WHERE (:facilityId IS NULL OR i.facilityId = :facilityId) AND l.formItemId = i.id AND i.formId = o.id) ORDER BY f.formDate DESC")
})
提取的查询字符串:
"SELECT f FROM FacilityForm f WHERE f.formDate BETWEEN :from and :to AND f.id In (SELECT o.id from InventoryLog l, FormItem i, FacilityForm o WHERE (:facilityId IS NULL OR i.facilityId = :facilityId) AND l.formItemId = i.id AND i.formId = o.id) ORDER BY f.formDate DESC"
我知道如果我想在一个子查询中也使用主实体,我必须为它使用另一个别名,我相信我做到了(在子查询中使用:facilityform o)。
我的问题是,在我的窗体上调用它时出现以下错误:
Info: ERROR APPNAME - Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.ID)) AND (t2.FORM_ID = t1.ID.t1.ID)) AND (t3.DELETED <> 'deleted')) AND ((t2.DE' at line 1
Error Code: 1064
Call:
SELECT t0.ID, t0.FORM_TYPE, t0.BANK_ACCOUNT_NO, t0.BANK_NAME, t0.COMMENT_BOTTOM, t0.COMMENT_UP, t0.COMPANY_ID, t0.CREATED_BY, t0.CREATED_TS, t0.CURRENCY, t0.DAILY_RATE, t0.DELETED, t0.DELIVERY_DATE, t0.DIRECTION, t0.EMAIL_SENT, t0.EU_INTERNAL_BOO, t0.FOREIGN_LANG_BOO, t0.FORM_DATE, t0.FORM_NR, t0.IBAN, t0.MODIFIED_BY, t0.MODIFIED_TS, t0.PAYMENT_BOOKED, t0.PAYMENT_DATE, t0.PAYMENT_TERM, t0.PAYMENT_TYPE, t0.PRINTED_ORIG, t0.REVERSE_CHARGE_BOO, t0.STATE, t0.STATUS, t0.SUBTYPE, t0.SWIFT, t0.TITLE, t0.TYPE, t0.USER_ID, t0.VERSION, t0.ADDRESS_DATA_ID, t0.ADDRESS_ID, t0.CONTACT_ID, t0.CONTAINER_ID_FROM, t0.CONTAINER_ID_TO, t0.FACILITY_ID_FROM, t0.FACILITY_ID_TO, t0.JOB_ID, t0.PARTNER_DATA_ID, t0.PARTNER_ID, t0.RELATED_FORM_ID, t0.WS_ORDER_ID FROM form t0
WHERE (((((((t0.DIRECTION = ?)
AND (t0.FORM_DATE BETWEEN ? AND ?)) AND ((? IS NULL) OR (t0.MODIFIED_TS >= ?))) AND ((? IS NULL) OR (t0.MODIFIED_TS <= ?))) AND (t0.STATUS > ?)) AND t0.ID IN (SELECT t1.ID FROM inventory_log t3, form_item t2, form t1 WHERE ((((((? IS NULL) OR (t2.FACILITY_ID = ?)) AND (t3.FORM_ITEM_ID = t2.ID.t2.ID)) AND (t2.FORM_ID = t1.ID.t1.ID)) AND (t3.DELETED <> ?)) AND ((t2.DELETED <> ?) AND ((t1.DELETED <> ?) AND (t1.FORM_TYPE = ?)))))) AND ((t0.DELETED <> ?) AND (t0.FORM_TYPE = ?))) ORDER BY t0.FORM_DATE DESC
bind => [16 parameters bound]
相关部分:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.ID)) AND (t2.FORM_ID = t1.ID.t1.ID)) AND (t3.DELETED <> 'deleted')) AND ((t2.DE' at line 1
有人能帮帮我吗?有什么问题吗?
谢谢您。
暂无答案!
目前还没有任何答案,快来回答吧!