问题描述
我有一个直到最近才开始工作的hibernate映射 - 虽然我确定这是我做出的一些更改的结果,但我似乎无法找到它。
映射文件将字段定义为:
< id name =idcolumn =id >
< generator class =native/>
< / id>
该类将此字段定义为:
私人长ID;
public Long getId(){
return id;
}
public void setId(Long id){
this.id = id;
}
运行此代码时,出现以下错误:
org.hibernate.PropertyAccessException:
调用MyClass.id的setter时发生IllegalArgumentException
与此对应的数据库字段定义为:
`id` bigint(20)NOT NULL AUTO_INCREMENT PRIMARY KEY
类似的结构和定义,并没有与他们的问题。但是,可能是由于我最近做出的一些更改而导致的,这个特定的映射将不再正常工作。
有什么建议吗?
< / p>
id name =idtype =java.lang.Long>
< column name =id/>
< generator class =native/>
< / id>
Hibernate可能会设置错误的值。
I have a hibernate mapping which was working until recently - and while I'm sure this is the result of some change I've made, I can't seem to find it.
The mapping file defines a field as:
<id name="id" column="id"> <generator class="native" /> </id>
The class defines this field as:
private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; }
When I run this code, I get the following error:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of MyClass.id
The database field to which this corresponds is defined as:
`id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
I have several other classes with similar structures and definitions, and have no issues with them. However, likely resulting from some recent change I made, this one particular mapping will no longer work properly.
Any suggestions?
解决方案I am not sure but you can try this :
<id name="id" type="java.lang.Long"> <column name="id" /> <generator class="native" /> </id>
Hibernate may be setting wrong value.
这篇关于Hibernate PropertyAccessException:IllegalArgumentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 03:39