测试代码如下:
session.getTransaction().begin();
Address address=(Address)session.load(Address.class, 1);;
Userinfo userinfo=new Userinfo();
userinfo.setAddress(address);
userinfo.setUser(user);
session.getTransaction().commit();
session.getTransaction().begin();
Address address=(Address)session.load(Address.class, 1);;
Userinfo userinfo=new Userinfo();
userinfo.setAddress(address);
userinfo.setUser(user);
session.getTransaction().commit();
解决方案 »
- 使用atomikos 配置的数据源,急 在线等
- java.lang.ClassNotFoundException: webservice.WebServiceListener,求解!
- 如何用JMS传递SOAP消息啊?
- ssh配置问题
- 求输入流解析程序
- 遇到一个很棘手的问题,关于hibernate的,请达人解答啊
- 求教:用过Struts + SessionBean + Hibernate架构开发程序的朋友请进来!(分不够到时再加)
- Weblogic8的问题,请大家指教
- Struts初学:存储在hsahMap中的信息如何用logic标签的重复标记iterrate输出到jsp页面中
- 在jb中bmp的测试程序出错!!
- 高分求助bean:writ问题,高手请进阿!!!!在线等!!!
- 请教:JAMES服务器向外网发送邮件失败如何解决
session.getTransaction().begin();
Address address=(Address)session.load(Address.class, 1);;
Userinfo userinfo=new Userinfo();
userinfo.setAddress(address);
session.save(userinfo);
session.getTransaction().commit();
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.test.Client.main(Client.java:77)
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails (`cityu`.`userinfo`, CONSTRAINT `FKF02772F95CA635D4` FOREIGN KEY (`addressid`) REFERENCES `address` (`id`))"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1540)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 8 more