在我的 Java 应用程序中,我有一个表用户,并且这个表有only one value
(这在数据库中只有一个值很重要)。
现在我只是使用 UserVO bean 更新用户表..
这只是一个简单的更新逻辑
public void updateUserVO(UserVO uservo)throws DataAccessException {
-------//set values
entityManager.merge(uservo);
entityManager.flush();
}
但我得到
SEVERE: Servlet.service() for servlet [spring] in context with path [/EClass] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.HibernateException: More than one row with the given identifier was found: U1, for class: com.sits.ec.valueObjects.UserVO] with root cause
org.hibernate.HibernateException: More than one row with the given identifier was found: U1, for class: com.sits.ec.valueObjects.UserVO
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:108)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3294)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
at org.hibernate.type.EntityType.resolve(EntityType.java:438)
---------
有趣的是......相同的代码运行另一个系统,并且在数据库中也只有一列......
而且我有近 10 次更新操作,它们使用相同的用户对象 ( id=U1
) 一小时前该代码运行良好,但现在至少有一个无法运行.. 每个更新的操作都会给出上述错误。
Specifications: OS - Ubuntu(Linux)
Database - MySql (Lamp Sever)
. 请帮我解决这个问题..