Hello,
I have tried several different ways to do what seems to me to be very common without success. If this is an easy one that I'm just missing, maybe someone can point me in the right direction. Have read the manual.
I have a class which has a bidirectional one-to-many association to a collection of entities, as in the manual section 8.2. Here is some of my cfg file:
<class name="com.fujisawa.compintel.app.to.DrugTO" table="intel_drugs">
<id name="drugId" type="long">
<column name="drug_id" sql-type="int" not-null="true"/>
<generator class="native"/>
</id>
<set name="names" inverse="true" cascade="all-delete-orphan">
<key column="drug_id"/>
<one-to-many class="com.fujisawa.compintel.app.to.NameTO"/>
</set>
...
<class name="com.fujisawa.compintel.app.to.NameTO"
table="intel_drug_names"
dynamic-update="true">
<id name="drugNameId" type="long">
<column name="drug_name_id" sql-type="int" not-null="true"/>
<generator class="native"/>
</id>
<many-to-one name="parent" column="drug_id" not-null="true"/>
<property name="name">
<column name="drug_name" sql-type="varchar(100)" not-null="true"/>
</property>
So a drug has several names. All I want is a query that returns DrugTO's for drugs which have a name = to my search criteria. The query I tries that seems to me most correct from the docs is this:
select d from DrugTO as d left join d.names as name where name.name ='aspirin'
which seems to load my entire database. There are sever other collections of classes that belong to drug similar to name, but I need to get one working first.
Thanks for any suggestions.
-Scott
|