多字段主键

hibernate4多字段主键配置方案

怎甘沉沦 提交于 2020-03-01 14:34:50
1.pom.xml文件参考 http://my.oschina.net/u/555061/blog/506049 2.这里使用注解方法(其实注解也就注解了2个字段为主键),给出hibernate.cfg.xml配置跟 http://my.oschina.net/u/555061/blog/506049 相同,只是映射类改为 <mapping class="EntityTest.Tour_Morph"/> 3.给出Tour_Morph.java, package EntityTest; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.Table; @Entity @IdClass(Tour_MorphID.class) @Table(name = "Tour_Morph") public class Tour_Morph { @Id @Column(name = "Tour_id") private Integer Tour_id; @Id @Column(name =