]
Vitaliy Morarian updated HHH-3861:
----------------------------------
Attachment: person-with-joined-subclass.hbm.xml
Wrong sql query with join table strategy
----------------------------------------
Key: HHH-3861
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3861
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Reporter: Vitaliy Morarian
Attachments: person-with-join-table.hbm.xml, person-with-joined-subclass.hbm.xml
I have found that use of join table strategy results wrong query. Changing strategy to
joined-subclass works ok.
produced SQL with join-table:
---
/* load one-to-many com.uwiss.hr.domain.Company.customers */ select
customers0_.company_id as company11_3_, customers0_.person_id as person1_3_,
customers0_.person_id as person1_16_2_, customers0_.version as version16_2_,
customers0_.contact_phone as contact4_16_2_, customers0_.email as email16_2_,
customers0_.memo as memo16_2_, customers0_.status as status16_2_, customers0_.first_name
as first8_16_2_, customers0_.last_name as last9_16_2_, customers0_.lock as lock16_2_,
customers0_1_.company_id as company2_17_2_, account1_.account_id as account1_0_0_,
account1_.username as username0_0_, account1_.password as password0_0_, account1_.enabled
as enabled0_0_, account1_.salt as salt0_0_, person2_.person_id as person1_16_1_,
person2_.version as version16_1_, person2_.contact_phone as contact4_16_1_, person2_.email
as email16_1_, person2_.memo as memo16_1_, person2_.status as status16_1_,
person2_.first_name as first8_16_1_, person2_.last_name as last9_16_1_, person2_.lock as
lock16_1_, person2_1_.company_id as company2_17_1_, person2_2_.birth as birth18_1_,
person2_2_.phone_home as phone3_18_1_, person2_2_.phone_mobile as phone4_18_1_,
person2_2_.ice_external as ice5_18_1_, person2_2_.ice_internal as ice6_18_1_,
person2_2_.vacation_size_id as vacation7_18_1_, person2_.discriminator as discrimi2_16_1_
from person customers0_ inner join customer customers0_1_ on
customers0_.person_id=customers0_1_.customer_id left outer join account account1_ on
customers0_.person_id=account1_.account_id left outer join person person2_ on
account1_.account_id=person2_.person_id left outer join customer person2_1_ on
person2_.person_id=person2_1_.customer_id left outer join employee person2_2_ on
person2_.person_id=person2_2_.employee_id where customers0_.company_id=?
ERROR: column customers0_.company_id does not exist
---
Produced SQL with joined-subclass strategy:
/* load one-to-many com.uwiss.hr.domain.Company.customers */ select
customers0_.company_id as company2_3_, customers0_.customer_id as customer1_3_,
customers0_.customer_id as person1_16_2_, customers0_1_.version as version16_2_,
customers0_1_.contact_phone as contact3_16_2_, customers0_1_.email as email16_2_,
customers0_1_.memo as memo16_2_, customers0_1_.status as status16_2_,
customers0_1_.first_name as first7_16_2_, customers0_1_.last_name as last8_16_2_,
customers0_1_.lock as lock16_2_, customers0_.company_id as company2_17_2_,
account1_.account_id as account1_0_0_, account1_.username as username0_0_,
account1_.password as password0_0_, account1_.enabled as enabled0_0_, account1_.salt as
salt0_0_, person2_.person_id as person1_16_1_, person2_.version as version16_1_,
person2_.contact_phone as contact3_16_1_, person2_.email as email16_1_, person2_.memo as
memo16_1_, person2_.status as status16_1_, person2_.first_name as first7_16_1_,
person2_.last_name as last8_16_1_, person2_.lock as lock16_1_, person2_1_.company_id as
company2_17_1_, person2_2_.birth as birth18_1_, person2_2_.phone_home as phone3_18_1_,
person2_2_.phone_mobile as phone4_18_1_, person2_2_.ice_external as ice5_18_1_,
person2_2_.ice_internal as ice6_18_1_, person2_2_.vacation_size_id as vacation7_18_1_,
case when person2_1_.customer_id is not null then 1 when person2_2_.employee_id is not
null then 2 when person2_.person_id is not null then 0 end as clazz_1_ from customer
customers0_ inner join person customers0_1_ on
customers0_.customer_id=customers0_1_.person_id left outer join account account1_ on
customers0_.customer_id=account1_.account_id left outer join person person2_ on
account1_.account_id=person2_.person_id left outer join customer person2_1_ on
person2_.person_id=person2_1_.customer_id left outer join employee person2_2_ on
person2_.person_id=person2_2_.employee_id where customers0_.company_id=?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: