• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0];

 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new in Hibernate and i am doing these examples locally , but getting below error for many-to-many mapping:



Below are my code files

Student.java



Course.java



Here are the hbm files for both the above java classes

Student.hbm.xml



Course.hbm.xml



And finally my Testing class



Am i missing something or have i added something extra in hbm files ?
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Try one of these 2 suggestions, either one should solve your problem. You shouldn't have to use both of them:

1) Explicitly save the course object before saving the student object.

2) Inverse your inverse relationships, make Student inverse=true and Course inverse=false; In the code you posted, Course is the owner of the relationship so Student would not update Course.

That is what to come to mind at first glance.
 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks A.J. Côté , First solution worked but the second one is not working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic