Hibernate克隆对象
如果有两个MODEL(A,A_log) ,A_log包含A的所有元素(包括A的ID),A_log唯一多的字段是自己的ID,那么在想在修改A之前的时候记录他的结果到A_log表中。可以这样写:
可以在A_log的MODEL中加一行:private A a;(set,get方法)
然后在A_log.xml中这样写:
<hibernate-mapping>
<class name="ie.cdclab.detect.eruption.model.LabEruptionBDectctLog" table="LAB_ERUPTION_B_DECTCT_LOG" schema="LAB">
<comment>发热伴出疹细菌检测表_log。</comment>
<id name="idEruptionBDectctLog" type="java.lang.String">
<column name="ID_ERUPTION_B_DECTCT_LOG" length="40" />
<generator class="uuid" />
</id>
<component name="labEruptionBDetect"> --用这个把相同的元素包起来,labEruptionBDetect是原表
<property name="idEruptionBDectct" type="java.lang.String">
<column name="ID_ERUPTION_B_DECTCT" length="40" not-null="true">
<comment>发热伴出疹细菌检测表ID。</comment>
</column>
</property>
<property name="idSampleinfo" type="java.lang.String">
<column name="ID_SAMPLEINFO" length="40" not-null="true">
<comment>标本信息ID。</comment>
</column>
</property>
</component>
</class>
</hibernate-mapping>然后在service中:
public void saveLog(LabEruptionBDetect LabEruptionBDetect) {
// TODO Auto-generated method stub
LabEruptionBDectctLog LabEruptionBDetectLog = new LabEruptionBDectctLog();
LabEruptionBDetectLog.setLabEruptionBDetect(LabEruptionBDetect);
dao.save(LabEruptionBDetectLog);
} 相关推荐
zhuxue 2020-10-14
zhangbingb 2020-09-21
HeronLinuxampARM 2020-09-14
美丽的泡沫 2020-09-08
goodstudy 2020-08-19
luvhl 2020-08-17
littleFatty 2020-08-16
gamestart0 2020-08-15
URML 2020-08-15
sfkong 2020-08-02
82941732 2020-07-27
偏头痛杨 2020-07-18
timewind 2020-07-04
89407707 2020-06-27
xiaoxiaoCNDS 2020-06-26
lyjava 2020-06-26
运算符用于执行程序代码运算,会针对一个以上操作数项目来进行运算。以上实例中 7、5 和 12 是操作数。关系运算符用于计算结果是否为 true 或者 false。逻辑运算符用于测定变量或值之间的逻辑。
ChaITSimpleLove 2020-06-25
Strongding 2020-06-25