Another question about collection.
2 tables
Property and Company.
Code:
<hibernate-mapping>
<class
name="com.clearview.feedback.db.language.MultiLanguageProperty"
table="multilanguage_property"
dynamic-update="false"
dynamic-insert="false"
mutable="true"
>
<id
name="id"
column="prop_id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="sequence">multi_lang_seq</param>
</generator>
</id>
<discriminator
column="disc"
type="string"
/>
.................
.................
.................
<subclass
name="com.clearview.feedback.db.language.CompanyProperty"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="comp"
>
</subclass>
</class>
</hibernate-mapping>
Such code
Code:
Company newCompany = (Company) session.
loadSingleObject(Company.class, companyId);
List properties = newCompany.getProperties();
is invoked such sql query
Code:
select multilan0_.prop_id as prop_id__, language1_.lang_id as lang_id0_, language1_.name as name0_, language1_.description as descript3_0_, multilan0_.prop_id as prop_id1_, multilan0_.lang_id as lang_id1_, multilan0_.name as name1_, multilan0_.value as value1_, multilan0_.description as descript6_1_, multilan0_.ref_id as ref_id1_ from multilanguage_property multilan0_ left outer join language language1_ on multilan0_.lang_id=language1_.lang_id where multilan0_.ref_id=?
As you can see this sql query selects all properties with id like company id, but it should select properties with id = company.id and disc = 'comp'
And when i invoke
Code:
session.delete(newCompany);
SQL query is
Code:
delete from multilanguage_property where prop_id=?
Again such situation...
What shoud i do to select and delete only CompanyProperty objects?