以下是我的代码摘录(我正在使用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”子句?
答案 0 :(得分:0)
您需要将status.lookup_type = 'WIP_JOB_STATUS'
添加到您的条件列表中。
您尚未提供查询,因此无法修复该部分。