【发布时间】:2017-03-03 10:11:33
【问题描述】:
我在尝试使用 spring MVC 和休眠将数据保存到数据库时遇到以下异常:
[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_id 字段。
【问题讨论】:
-
是的,txnId 是整数
-
用正确的表检查一次映射
标签: mysql hibernate spring-mvc