org.hibernate.DuplicateMappingException:表包含由多个物理列名称引用的物理列名称[coverage_name]:

时间:2018-08-20 11:54:32

标签: java spring-boot jpa hibernate-mapping

我正在使用下面的类,但是给出了类似的异常,原因如下:org.hibernate.DuplicateMappingException:表[]包含由多个物理列名称引用的物理列名称[scheme_name]:[SCHEME],[schemeName]帮助我解决这个问题。

#Send a text from bot to channel by forward
@bot.message_handler(func=lambda message: True)
    def main(message):
        if message.forward_from_chat:
            apiuz=message.forward_from_chat
            count = bot.get_chat_members_count(apiuz.id)
            bot.send_message(chat_id, count)

这是实体,我试图通过使用该Embeddable类使用复合键。

@Embeddable
public class DRollSchemesId implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "ROLL_NO", length = 20)
    private String rollNo;

    @Id
    @Column(name = "SCHEME", length = 100, updatable = false, insertable = false )
    private String schemeName;

   public DRollSchemesId() {
   }

   public DRollSchemesId(String rollNo, String schemeName) {
      this.rollNo = rollNo;
      this.schemeName = schemeName;
   }

   public String getrollNo() {
       return this.rollNo;
   }

   public void setrollNo(String rollNo) {
       this.rollNo = rollNo;
   }
   public String getschemeName() {
       return this.schemeName;
   }

   public void setschemeName(String schemeName) {
       this.schemeName = schemeName;
   }

1 个答案:

答案 0 :(得分:0)

请尝试以下操作:

class DRollSchemesId implements Serializable {
    private String rollNo;
    private String schemeName;
}

@Entity
@Table(name = "D_ROLL_SCHEMES")
@IdClass(DRollSchemesId.class)
public class DRenewalAddonCoverages implements java.io.Serializable {

    @Id
    @Column(name = "ROLL_NO", length = 20)
    private String rollNo;

    @Id
    @Column(name = "SCHEME", length = 100, updatable = true, insertable = true)
    private String schemeName;

}