代码太长了,我就简单概述哈
代码: Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
报错: family=:null
Hibernate: insert into Zhijia_Gfamily_T_UserFamily (FamilyCode, FamilyNickName, FamilyNum, RegisterTime, MicroSignal, QQ, SinaTwitterNo, QQTwitterNo, Email, MolbilePhone, Remark, UserID, AvatarUrl) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
family=:44
Hibernate: select familyacco0_.AccountID as AccountID27_, familyacco0_.FamilyID as FamilyID27_, familyacco0_.AccountCode as AccountC3_27_, familyacco0_.NoticeState as NoticeSt4_27_, familyacco0_.CurGoldNum as CurGoldNum27_, familyacco0_.RecGoldNum as RecGoldNum27_, familyacco0_.PreGoldNum as PreGoldNum27_, familyacco0_.Remark as Remark27_ from Zhijia_Gfamily_T_FamilyAccount familyacco0_ order by familyacco0_.AccountID desc limit ?
Hibernate: insert into Zhijia_Gfamily_T_FamilyAccount (FamilyID, AccountCode, NoticeState, CurGoldNum, RecGoldNum, PreGoldNum, Remark) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select user0_.UserID as UserID33_, user0_.FamilyID as FamilyID33_, user0_.UserCode as UserCode33_, user0_.MolbilePhone as MolbileP4_33_, user0_.Password as Password33_, user0_.MicroSignal as MicroSig6_33_, user0_.QQ as QQ33_, user0_.SinaTwitterNo as SinaTwit8_33_, user0_.QQTwitterNo as QQTwitte9_33_, user0_.Email as Email33_, user0_.RealName as RealName33_, user0_.NickName as NickName33_, user0_.Sex as Sex33_, user0_.OnlineGameID as OnlineG14_33_, user0_.RegisterTime as Registe15_33_, user0_.Remark as Remark33_, user0_.SinaCode as SinaCode33_, user0_.QQCode as QQCode33_, user0_.isHead as isHead33_, user0_.MachineCode as Machine20_33_, user0_.IsVisitor as IsVisitor33_, user0_.AvatarID as AvatarID33_, user0_.RoleID as RoleID33_ from Zhijia_Gfamily_T_User user0_ where user0_.MachineCode=? and user0_.IsVisitor=0
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
再补充一段: Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
#15
不知道呢 我该怎么测试呢
补充:我朋友通过访问我的tomcat,并没有出现这种情况,
#16
你写个test去对数据库进行插入,试试,,,
#17
代码:
Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13];
=====================================
作为ID 13的User对象已经存在了,这个你需要看下关于Hibernate的Entity管理状态
由于你的User是new出来的,保存后能打印ID,不知道你的Dao里是怎么写的...是数据库自增的吗,还是如何赋值的。
这种错误一般由于两个主键相同的对象,在不同事务中,且不同的管理状态下,hibernate无法区分你要保存的对象才会出现的,因为保存时,hibernate还会去检查内存的
再补充一段: Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
代码太长了,我就简单概述哈
代码: Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
报错: family=:null
Hibernate: insert into Zhijia_Gfamily_T_UserFamily (FamilyCode, FamilyNickName, FamilyNum, RegisterTime, MicroSignal, QQ, SinaTwitterNo, QQTwitterNo, Email, MolbilePhone, Remark, UserID, AvatarUrl) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
family=:44
Hibernate: select familyacco0_.AccountID as AccountID27_, familyacco0_.FamilyID as FamilyID27_, familyacco0_.AccountCode as AccountC3_27_, familyacco0_.NoticeState as NoticeSt4_27_, familyacco0_.CurGoldNum as CurGoldNum27_, familyacco0_.RecGoldNum as RecGoldNum27_, familyacco0_.PreGoldNum as PreGoldNum27_, familyacco0_.Remark as Remark27_ from Zhijia_Gfamily_T_FamilyAccount familyacco0_ order by familyacco0_.AccountID desc limit ?
Hibernate: insert into Zhijia_Gfamily_T_FamilyAccount (FamilyID, AccountCode, NoticeState, CurGoldNum, RecGoldNum, PreGoldNum, Remark) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select user0_.UserID as UserID33_, user0_.FamilyID as FamilyID33_, user0_.UserCode as UserCode33_, user0_.MolbilePhone as MolbileP4_33_, user0_.Password as Password33_, user0_.MicroSignal as MicroSig6_33_, user0_.QQ as QQ33_, user0_.SinaTwitterNo as SinaTwit8_33_, user0_.QQTwitterNo as QQTwitte9_33_, user0_.Email as Email33_, user0_.RealName as RealName33_, user0_.NickName as NickName33_, user0_.Sex as Sex33_, user0_.OnlineGameID as OnlineG14_33_, user0_.RegisterTime as Registe15_33_, user0_.Remark as Remark33_, user0_.SinaCode as SinaCode33_, user0_.QQCode as QQCode33_, user0_.isHead as isHead33_, user0_.MachineCode as Machine20_33_, user0_.IsVisitor as IsVisitor33_, user0_.AvatarID as AvatarID33_, user0_.RoleID as RoleID33_ from Zhijia_Gfamily_T_User user0_ where user0_.MachineCode=? and user0_.IsVisitor=0
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
代码太长了,我就简单概述哈
代码: Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
报错: family=:null
Hibernate: insert into Zhijia_Gfamily_T_UserFamily (FamilyCode, FamilyNickName, FamilyNum, RegisterTime, MicroSignal, QQ, SinaTwitterNo, QQTwitterNo, Email, MolbilePhone, Remark, UserID, AvatarUrl) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
family=:44
Hibernate: select familyacco0_.AccountID as AccountID27_, familyacco0_.FamilyID as FamilyID27_, familyacco0_.AccountCode as AccountC3_27_, familyacco0_.NoticeState as NoticeSt4_27_, familyacco0_.CurGoldNum as CurGoldNum27_, familyacco0_.RecGoldNum as RecGoldNum27_, familyacco0_.PreGoldNum as PreGoldNum27_, familyacco0_.Remark as Remark27_ from Zhijia_Gfamily_T_FamilyAccount familyacco0_ order by familyacco0_.AccountID desc limit ?
Hibernate: insert into Zhijia_Gfamily_T_FamilyAccount (FamilyID, AccountCode, NoticeState, CurGoldNum, RecGoldNum, PreGoldNum, Remark) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select user0_.UserID as UserID33_, user0_.FamilyID as FamilyID33_, user0_.UserCode as UserCode33_, user0_.MolbilePhone as MolbileP4_33_, user0_.Password as Password33_, user0_.MicroSignal as MicroSig6_33_, user0_.QQ as QQ33_, user0_.SinaTwitterNo as SinaTwit8_33_, user0_.QQTwitterNo as QQTwitte9_33_, user0_.Email as Email33_, user0_.RealName as RealName33_, user0_.NickName as NickName33_, user0_.Sex as Sex33_, user0_.OnlineGameID as OnlineG14_33_, user0_.RegisterTime as Registe15_33_, user0_.Remark as Remark33_, user0_.SinaCode as SinaCode33_, user0_.QQCode as QQCode33_, user0_.isHead as isHead33_, user0_.MachineCode as Machine20_33_, user0_.IsVisitor as IsVisitor33_, user0_.AvatarID as AvatarID33_, user0_.RoleID as RoleID33_ from Zhijia_Gfamily_T_User user0_ where user0_.MachineCode=? and user0_.IsVisitor=0
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
再补充一段: Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
#15
事物是不是没有提交啊,妹子,,,
不知道呢 我该怎么测试呢
补充:我朋友通过访问我的tomcat,并没有出现这种情况,
#16
你写个test去对数据库进行插入,试试,,,
#17
代码:
Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13];
=====================================
作为ID 13的User对象已经存在了,这个你需要看下关于Hibernate的Entity管理状态
由于你的User是new出来的,保存后能打印ID,不知道你的Dao里是怎么写的...是数据库自增的吗,还是如何赋值的。
这种错误一般由于两个主键相同的对象,在不同事务中,且不同的管理状态下,hibernate无法区分你要保存的对象才会出现的,因为保存时,hibernate还会去检查内存的
再补充一段: Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
代码太长了,我就简单概述哈
代码: Family family=new Family();
System.out.println("family="+family.getId());
familyDao.save(family);
System.out.println("family="+family.getId());
User user=new User();
user.setFamily(family);
userDao.save(user);
报错: family=:null
Hibernate: insert into Zhijia_Gfamily_T_UserFamily (FamilyCode, FamilyNickName, FamilyNum, RegisterTime, MicroSignal, QQ, SinaTwitterNo, QQTwitterNo, Email, MolbilePhone, Remark, UserID, AvatarUrl) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
family=:44
Hibernate: select familyacco0_.AccountID as AccountID27_, familyacco0_.FamilyID as FamilyID27_, familyacco0_.AccountCode as AccountC3_27_, familyacco0_.NoticeState as NoticeSt4_27_, familyacco0_.CurGoldNum as CurGoldNum27_, familyacco0_.RecGoldNum as RecGoldNum27_, familyacco0_.PreGoldNum as PreGoldNum27_, familyacco0_.Remark as Remark27_ from Zhijia_Gfamily_T_FamilyAccount familyacco0_ order by familyacco0_.AccountID desc limit ?
Hibernate: insert into Zhijia_Gfamily_T_FamilyAccount (FamilyID, AccountCode, NoticeState, CurGoldNum, RecGoldNum, PreGoldNum, Remark) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select user0_.UserID as UserID33_, user0_.FamilyID as FamilyID33_, user0_.UserCode as UserCode33_, user0_.MolbilePhone as MolbileP4_33_, user0_.Password as Password33_, user0_.MicroSignal as MicroSig6_33_, user0_.QQ as QQ33_, user0_.SinaTwitterNo as SinaTwit8_33_, user0_.QQTwitterNo as QQTwitte9_33_, user0_.Email as Email33_, user0_.RealName as RealName33_, user0_.NickName as NickName33_, user0_.Sex as Sex33_, user0_.OnlineGameID as OnlineG14_33_, user0_.RegisterTime as Registe15_33_, user0_.Remark as Remark33_, user0_.SinaCode as SinaCode33_, user0_.QQCode as QQCode33_, user0_.isHead as isHead33_, user0_.MachineCode as Machine20_33_, user0_.IsVisitor as IsVisitor33_, user0_.AvatarID as AvatarID33_, user0_.RoleID as RoleID33_ from Zhijia_Gfamily_T_User user0_ where user0_.MachineCode=? and user0_.IsVisitor=0
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.zhijia.gfamily.po.player.User#13]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)