数据保存到MYSQL数据库中

数据保存到MYSQL数据库中,mysql,hibernate,spring-mvc,Mysql,Hibernate,Spring Mvc,我在尝试使用spring MVC和hibernate将数据保存到数据库时遇到以下异常: [INFO] 2017-03-03 15:26:22,487 stdout write - org.springframework.beans.InvalidPropertyException: Invalid property 'txnId' of bean class [com.entity.TxnCustomer]: Getter for property 'txnId' threw exc

我在尝试使用spring MVC和hibernate将数据保存到数据库时遇到以下异常:

    [INFO] 2017-03-03 15:26:22,487 
stdout write - org.springframework.beans.InvalidPropertyException: 
Invalid property 'txnId' of bean class [com.entity.TxnCustomer]: Getter for property 'txnId' threw exception; nested exception is java.lang.reflect.InvocationTargetException
实体的一部分:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="TXN_ID")
private Integer txnId;


public TxnCustomer() {
}

public Integer getTxnId() {
    return this.txnId;
}

public void setTxnId(Integer txnId) {
    this.txnId = txnId;
}
我不明白为什么会发生这种异常


mysql数据库包含设置为自动递增的
txn\u id
字段。

使用int而不是Integer

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="TXN_ID")
private int txnId;

public TxnCustomer() {
}

public int getTxnId() {
  return this.txnId;
}

public void setTxnId(int txnId) {
  this.txnId = txnId;
}

是的,txnId是integercheck,一旦映射到正确的表