Hibernate annotations 联合主键注解

@Entity
@Table(name="tbl_product")
public class Product extends BaseProductJoin{

}

@MappedSuperclass//该注解的作用是指不用把该父类作为映射实体来处理
public class BaseProductJoin implements Serializable {
     /** The id. */
     @EembeddedId//用于组件属性的注解
     private ProductJoinJoinPK id;
     
     /**********Getter/Setter************/
}

@Embeddable//用于组件类的注解
public class ProductJoinJoinPK extends BaseProductJoinJoinPK{

} 

@MappedSuperclass
public class BaseProductJoinJoinPK implements Serializable {
       /** The id product. */
        @Column(name="id_product")
	private Integer idProduct;

	/** The id user. */
        @Column(name="id_user")
	private Integer idUser;
        
        /**********Getter/Setter************/  
}

你可能感兴趣的:(Hibernate)