• 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!