我有两个类与Hibernate绑定映射,我无法弄清楚将配置映射到药物条目到我的规定药物类。休眠映射一对一
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;
...
}
我的数据模型是这样的:
prescribed_drug drug
---------- --------------
prescribed_drug_id* drug_id*
drug_id* name
sig ....
...
这里是我的Hibernate配置:
<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>
注意在这里,我想我的药物映射在PrescribedDrug.hbm.xml配置使用一到一个但休眠不断告诉我添加字段药物到PrescribedDrug文件...
区[name]不org.example.smartgwt.shared找到。 model.PrescribedDrug
条目中药物表是静态的,包含处方药的性质。
谢谢。
我不明白的是这'私人诠释drugId;'的'PrescribedDrug'类。 – 2010-07-24 00:39:01
不应该在那里......我因为Hibernate而添加了它。但是我在最终版本中删除了它。我在映射中遇到了一些错误,由于@ hvgotcodes而得到修复。 – 2010-07-24 12:26:44