Here's an excerpt from my code (I'm using 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;
}
}
And here's some database definitions:
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
When I query on WipDiscreteJob and try to get a count of the results (using Criterias), the SQL, in part, looks like
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'
and I get an "invalid number" error when I run it. But when I add the "where" clause from the class...
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'
and run it manually, it runs fine. Is this just a bug in Hibernate or am I missing something? How do I get Hibernate to add that "where" clause?