Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.BatchUpdateException

 
Priya Joshi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In my application there are two tables User and Blog..
and relationship between them is one-to-many..

my code in hbm.xml is:

<class name="UserInfo">
<id name="userid" column="USER_ID">
<generator class="increment"></generator>
</id>

<property name="username" column="USER_NAME"></property>
<property name="password" column="PASSWORD"></property>

<set name="blog" cascade="save-update">
<key column="BLOG_ID"></key>
<one-to-many class="BlogInfo" not-found="ignore"/>
</set>

</class>


<class name="BlogInfo">
<id name="blogid" column="BLOG_ID">
<generator class="increment"></generator>
</id>

<property name="blogtitle" column="BLOG_TITLE"></property>
<property name="blogurl" column="BLOG_URL"></property>

<many-to-one name="userInfo" column="USER_ID" foreign-key="FK_User_ID" cascade="save-update"></many-to-one>
</class>

I can add one blog for user
but I am getting following exception when i try to add second blog for the same user in database(MYSQL)

I am giving stack trace:

java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`blog_tool_db/bloginfo`, CONSTRAINT `FKDC66CB9040393DCF` FOREIGN KEY (`BLOG_ID`) REFERENCES `userinfo` (`USER_ID`))
com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
com.wissen.blog.backend.facade.impl.NewBlogFacadeImpl.authenticateBlogUrl(NewBlogFacadeImpl.java:130)
com.wissen.blog.managedbeans.BlogMB.newblog(BlogMB.java:86)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)


Please help me...
its really urgent..



Thanks

[ October 08, 2008: Message edited by: Priya Joshi ]
[ October 08, 2008: Message edited by: Priya Joshi ]
 
sowmya sree bhagavatula
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello.. did your error disappear?

could you please tell me how.. i am facing the same trouble...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic