identifier of an instance of xxx was altered from 1 to 1

简介:

今天测试一个项目,这个项目使用了hibernatespring,报错信息如下:

Xml代码   收藏代码
  1. org.springframework.orm.hibernate4.HibernateSystemException: identifier of an instance of com.tdr.push.entity.ThreadPushFail was altered from 1 to 1; nested exception is org.hibernate.HibernateException: identifier of an instance of com.tdr.push.entity.ThreadPushFail was altered from 1 to 1  

 后来发现是因为实体类中id的属性和hbm.xml配置文件中id的属性不一致造成的。

我实体类中的id属性是:

Java代码   收藏代码
  1. public class ThreadPushFail {  
  2.     private long id;  
  3.     /*** 
  4.      * 推送消息的id 
  5.      */  
  6.     private long pushMessageId;  

 

hbm.xml配置文件中id的属性:

Xml代码   收藏代码
  1. <hibernate-mapping>  
  2.     <class name="com.tdr.push.entity.ThreadPushFail" table="t_threadPushFail" lazy="true">  
  3.         <id name="id" type="int">  
  4.             <column name="ID" precision="19" scale="0">  
  5.                 <comment>主键id</comment>  
  6.             </column>  
  7.             <generator class="identity"/>  
  8.         </id>  

 一个是int,一个是long

解决方案:是id的属性保持一致。

 

参考:http://blog.csdn.net/lsbhjshyn/article/details/5287554

相关文章
|
2月前
|
SQL 容灾 关系型数据库
PSQLException: ERROR: column “xxxxx“ does not exist
PSQLException: ERROR: column “xxxxx“ does not exist
75 0
|
JavaScript 算法 前端开发
Property xxx was accessed during render but is not defined on instance
目前el-form的model主要用表单验证的,也就是配合el-form的rules和el-form-item的prop来使用的。不信的话,你可以增加一个rules和prop(为了调用验证方法,也el-form也加一个ref属性,相当于id或者class选择器的意思),但是不写model,然后验证的话,会提示缺少model,导致无法验证成功。
Property xxx was accessed during render but is not defined on instance
解决Only void and foreign elements can be self closed “ xxxx-xxxx“报错
解决Only void and foreign elements can be self closed “ xxxx-xxxx“报错
解决Only void and foreign elements can be self closed “ xxxx-xxxx“报错
|
Java
The type XXX cannot be resolved. It is indirectly referenced from required .class files
The type XXX cannot be resolved. It is indirectly referenced from required .class files
131 0
Target class [Admin\LoginController] does not exist.
Laravel 8配置好路由后,访问提示:Target class [XXXXXController] does not exist.错误。出现这个错误的原因是Laravel8对路由命名空间做出了更新(详见:路由命名空间更新),而我们仍然在使用Laravel6或者7版本的方式写路由。 Laravel 8路由配置方式: use App\Http\Controllers\LoginController; Route::get('login', [LoginController::class, 'index']);
|
SQL 关系型数据库 数据库
ORA-04028: cannot generate diana for object xxx
在ORACLE数据库(10.2.0.5.0)上修改一个包的时候,编译有错误,具体错误信息为"ORA-04028: cannot generate diana for object xxx"。   Warning: Package Body created with compilation errors.
1569 0
|
SQL
ORA-02292: integrity constraint (xxxx) violated - child record found
在更新表的主键字段或DELETE数据时,如果遇到ORA-02292: integrity constraint (xxxx) violated - child record found 这个是因为主外键关系,下面借助一个小列子来描述一下这个错误: SQL> create table studen...
2378 0