Hi, I have two classes binded mapped with Hibernate and I can't figure out the configuration to map a Drug entry to my PrescribedDrug class.
public class PrescribedDrug implements Serializable {
protected int prescribedDrugId;
private int drugId;
protected String sig;
protected int quantity;
protected int refillNumber;
protected Drug drugInfo;
...
}
public class Drug implements Serializable {
protected int drugId;
protected String name;
protected double strength;
protected String strengthUnits;
...
}
My data model looks like this:
prescribed_drug drug
---------- --------------
prescribed_drug_id* drug_id*
drug_id* name
sig ....
...
Here is my hibernate configuration:
<hibernate-mapping>
<class name="org.example.smartgwt.shared.model.PrescribedDrug" table="prescribed_drug" lazy="false">
<id name="prescribedDrugId" column="prescribed_drug_id">
<generator class="assigned"/>
</id>
<property name="drugId">
<column name="drug_id"/>
</property>
<property name="sig">
<column name="sig"/>
</property>
<property name="quantity">
<column name="quantity"/>
</property>
<property name="refillNumber">
<column name="refill_number"/>
</property>
<one-to-one name="drugInfo" class="org.example.smartgwt.shared.model.Drug" lazy="false" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="org.example.smartgwt.shared.model.PrescribedDrug" table="prescribed_drug" lazy="false">
<id name="drugId" column="drug_id">
<generator class="assigned"/>
</id>
<property name="name">
<column name="name"/>
</property>
<property name="strength">
<column name="strength"/>
</property>
<property name="strengthUnits">
<column name="strength_units"/>
</property>
</class>
</hibernate-mapping>
NOTE here that I tried to map my Drug in the PrescribedDrug.hbm.xml config using a one-to-one but hibernate keeps telling me to add the fields of Drug to the PrescribedDrug file...
field [name] not found on org.example.smartgwt.shared.model.PrescribedDrug
Entries in drug table are a static and contains the properties of the prescribed drugs.
Thank you.