|
Assume that Employee and User are two models, the mapping
is like this:
<class identity="id"
key-generator="HIGH-LOW"
name="model.User">
<map-to table="user" /> <field name="id" type="integer"> <sql name="id" type="integer" /> </field> <field name="userType" type="string"> <sql name="user_type" type="varchar" /> </field> </class> <class identity="id"
key-generator="HIGH-LOW" name="model.Employee"
extends="model.User"> <map-to table="employee" /> <field name="id" type="integer"> <sql name="id" type="integer" /> </field> <field name="department" type="string"> <sql name="department" type="varchar" /> </field> </class> I can get the employee number with:
select count(e.id) from Employee e
But this fails:
select count(e.id) from Employee e where
e.userType = ?
I traced into castor and find the final SQL would be explained
as:
select count(id) from employee where user.user_type =
?
Obviously, the user table is not in the from clause, the
execution will fail. I'm not sure if it is caused by my misusage or is a
bug.
No matter how, could anybody provide me a solution to solve
this problem? (I don't want to use CALL SQL.)
Thanks,
Xiaoyong
|
