Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

Hibernate克隆对象

来源: zy116494718 分享至:

如果有两个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); }


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史