I am having two tables
1.logindetails - userid(primary key),password
2.personaldetails-userid(foreign key reference of logindetails),name
when i tried to store the data it shows the following error:
Hibernate version:3.1
Mapping documents:logindetails.hbm.xml,personaldetails.hbm.xml
Code between sessionFactory.openSession() and session.close():
Personaldetails ps=new Personaldetails();
ps.setName("deva");
ps.setRollno(new Integer(34));
org.hibernate.exception.ConstraintViolationException: [b]Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:200)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:877)
at source.MainClass.main(MainClass.java:23)
Caused by: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:853)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:193)
... 6 more
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
[/b]
Name and version of the database you are using:MySQL 4
|