[英]hibernate not using where clause with inner join
這是我的代碼摘錄(我使用的是 XDoclet):
/**
* @hibernate.class table="WIP_DISCRETE_JOBS"
*/
public class WipDiscreteJob extends AuditedObject
{
private WipDiscreteJobStatus status;
/**
* @hibernate.many-to-one column="STATUS_TYPE"
*/
public WipDiscreteJobStatus getStatus()
{
return status;
}
}
/**
* @hibernate.class
* table="apps.mfg_lookups"
* where="lookup_type = 'WIP_JOB_STATUS'"
*/
public class WipDiscreteJobStatus extends ManufacturingLookup
{
/**
* @hibernate.id column="LOOKUP_CODE"
* generator-class="assigned"
*/
public Long getId()
{
return this.id;
}
}
這是一些數據庫定義:
APPS.MFG_LOOKUP (view)
Column Name Pk Data Type Null?
LOOKUP_TYPE VARCHAR2 (30 Byte) N
LOOKUP_CODE NUMBER Y
WIP_DISCRETE_JOBS
Column Name Pk Data Type Null?
STATUS_TYPE N NUMBER Yes
當我查詢 WipDiscreteJob 並嘗試獲取結果計數(使用 Criterias)時,部分 SQL 看起來像
select count(*) as y0_
from WIP_DISCRETE_JOBS this_
inner join apps.mfg_lookups wipdiscret2_ on this_.STATUS_TYPE=wipdiscret2_.LOOKUP_CODE
inner join WIP_ENTITIES wipentity1_ on this_.WIP_ENTITY_ID=wipentity1_.WIP_ENTITY_ID
inner join WIP_SCHEDULE_GROUPS wipschedul4_ on this_.SCHEDULE_GROUP_ID=wipschedul4_.SCHEDULE_GROUP_ID
inner join INV.MTL_SYSTEM_ITEMS_B item3_ on this_.PRIMARY_ITEM_ID=item3_.INVENTORY_ITEM_ID and this_.ORGANIZATION_ID=item3_.ORGANIZATION_ID
where wipentity1_.WIP_ENTITY_NAME is not null
and wipdiscret2_.LOOKUP_CODE=3
and item3_.PLANNER_CODE='A5'
and wipschedul4_.SCHEDULE_GROUP_NAME='Area 2'
我在運行它時收到“無效數字”錯誤。 但是當我從類中添加“where”子句時......
select count(*) as y0_
from WIP_DISCRETE_JOBS this_
inner join apps.mfg_lookups wipdiscret2_ on this_.STATUS_TYPE=wipdiscret2_.LOOKUP_CODE AND lookup_type = 'WIP_JOB_STATUS'
inner join WIP_ENTITIES wipentity1_ on this_.WIP_ENTITY_ID=wipentity1_.WIP_ENTITY_ID
inner join WIP_SCHEDULE_GROUPS wipschedul4_ on this_.SCHEDULE_GROUP_ID=wipschedul4_.SCHEDULE_GROUP_ID
inner join INV.MTL_SYSTEM_ITEMS_B item3_ on this_.PRIMARY_ITEM_ID=item3_.INVENTORY_ITEM_ID and this_.ORGANIZATION_ID=item3_.ORGANIZATION_ID
where wipentity1_.WIP_ENTITY_NAME is not null
and wipdiscret2_.LOOKUP_CODE=3
and item3_.PLANNER_CODE='A5'
and wipschedul4_.SCHEDULE_GROUP_NAME='Area 2'
並手動運行它,它運行良好。 這只是 Hibernate 中的一個錯誤還是我遺漏了什么? 如何讓 Hibernate 添加“where”子句?
您需要將status.lookup_type = 'WIP_JOB_STATUS'
添加到您的標准列表中。
您尚未提供查詢,因此無法修復該部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.