Forums Register Login

java.sql.BatchUpdateException

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
hello.. did your error disappear?

could you please tell me how.. i am facing the same trouble...
expectation is the root of all heartache - shakespeare. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2345 times.
Similar Threads
Exception in Deleting Parent and Child entity
Hibernate loads only first element of the collection
problem in one-to-many while saving
Many to Many Relation Error Driving Me Mad
hibernate many to one question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:01:16.