This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
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 ?
 
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.
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!