本文主要是介绍SpringDataJpa创建联合索引,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
创建联合索引对应类
/*** 作者:guoyzh* 时间:2019/12/30 14:58* 功能:戴镜视力复查联合主键*/
@Data
@Embeddable
public class VisualReexaminationUnionKey implements Serializable {@Column(name = "id")private String id;@Column(name = "c_review_date")private java.sql.Timestamp cReviewDate;
}
创建映射实体类
@Table(name = "qy_visual_reexamination")
@Entity
@Data
public class QyVisualReexamination {/*@Id@Column(nullable = true, name = "id")private String id;@Id@Column(nullable = true, name = "c_review_date")private java.sql.Timestamp cReviewDate;*/// 复合主键@EmbeddedIdprivate VisualReexaminationUnionKey id;@Column(nullable = true, name = "c_clientid")private String cClientid;@Column(nullable = true, name = "c_ygscode")private String cYgscode;@Column(nullable = true, name = "c_primary_vision_r")private String cPrimaryVisionR;@Column(nullable = true, name = "c_primary_vision_l")private String cPrimaryVisionL;@Column(nullable = true, name = "c_ball_r")private String cBallR;@Column(nullable = true, name = "c_ball_l")private String cBallL;@Column(nullable = true, name = "c_pole_r")private String cPoleR;@Column(nullable = true, name = "c_pole_l")private String cPoleL;@Column(nullable = true, name = "c_axes_r")private String cAxesR;@Column(nullable = true, name = "c_axes_l")private String cAxesL;@Column(nullable = true, name = "c_add_r")private String cAddR;@Column(nullable = true, name = "c_add_l")private String cAddL;@Column(nullable = true, name = "c_check_r")private String cCheckR;@Column(nullable = true, name = "c_check_l")private String cCheckL;@Column(nullable = true, name = "c_proposal")private String cProposal;@Column(nullable = true, name = "c_com")private String cCom;}
添加新数据
@Override
public Object addVisualReexamination(String id, String clientId, String reviewDate, String ygsCode, String primaryVisionR,String primaryVisionL, String ballR, String ballL, String poleR, String poleL, String axesR,String axesL, String addR, String addL, String checkR, String checkL, String proposal, String comId) {QyVisualReexamination bean = new QyVisualReexamination();// 生成联合索引VisualReexaminationUnionKey unionId = new VisualReexaminationUnionKey();unionId.setCReviewDate(Timestamp.valueOf(reviewDate));unionId.setId(id);bean.setId(unionId);bean.setCClientid(clientId);bean.setCYgscode(ygsCode);bean.setCPrimaryVisionR(primaryVisionR);bean.setCPrimaryVisionL(primaryVisionL);bean.setCBallR(ballR);bean.setCBallL(ballL);bean.setCPoleR(poleR);bean.setCPoleL(poleL);bean.setCAxesR(axesR);bean.setCAxesL(axesL);bean.setCAddR(addR);bean.setCAddL(addL);bean.setCCom(comId);bean.setCCheckR(checkR);bean.setCCheckL(checkL);bean.setCProposal(proposal);QyVisualReexamination save = mQyVisualReexaminationDao.save(bean);return save.getId();
}
这篇关于SpringDataJpa创建联合索引的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!