Caused by:
java.sql.SQLException: Duplicate entry '????' for key 'name'
我有一些数据放到了一个xml的文件中,然后倒入数据库。我在用junit进行测试的时候出现以下错误:
09:18:07,426 INFO InitSystemDatasImpl:68 - 导入模块【个人办公】
Hibernate: insert into T_Module (name, sn, url, orderNo, parentId) values (?, ?, ?, ?, ?)
09:18:07,426 INFO InitSystemDatasImpl:68 - 导入模块【我的办公桌】
Hibernate: insert into T_Module (name, sn, url, orderNo, parentId) values (?, ?, ?, ?, ?)
09:18:07,426 WARN
JDBCExceptionReporter:71 - SQL Error: 1062, SQLState: 23000
09:18:07,426 ERROR JDBCExceptionReporter:72 - Duplicate entry '????' for key 'name'
org.springframework.dao.DataIntegrityViolationException: could not insert: [com.djrj.oa.model.Module];
nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [com.djrj.oa.model.Module]
Caused by: org.hibernate.exception.
ConstraintViolationException: could not insert: [com.djrj.oa.model.Module]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2093)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2573)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:47)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:625)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:622)
at com.djrj.oa.manager.impl.InitSystemDatasImpl.importModules(InitSystemDatasImpl.java:67)
at com.djrj.oa.manager.impl.InitSystemDatasImpl.importModules(InitSystemDatasImpl.java:69)
at com.djrj.oa.manager.impl.InitSystemDatasImpl.addOrUpdateInitDatas(InitSystemDatasImpl.java:45)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)