|
Article.java and Section.java are zipped in attachment.
Article article = new Article();
article.setName("test");
List<Section> articles = article.getSections(); Section section1 = new Section();
section1.setName("test");
section1.setContent("test");
articles.add(section1);
Section section2 = new Section();
section2.setName("test");
section2.setContent("test");
articles.add(section2);
Section section3 = new Section();
section3.setName("test");
section3.setContent("test");
articles.add(section3);
session.save(article);
Article article = articleManager.get(1L);
article.setName("test");
List<Section> articles = new ArrayList<Section>();
Section section1 = new Section();
section1.setName("test");
section1.setContent("test");
articles.add(section1);
Section section2 = new Section();
section2.setName("test");
section2.setContent("test");
articles.add(section2);
Section section3 = new Section();
section3.setName("test");
section3.setContent("test");
articles.add(section3);
article.setSections(sections);
session.save(article);
Article article = articleManager.get(1L);
article.setName("test");
List<Section> articles = article.getSections(); articles.clear();
Section section1 = new Section();
section1.setName("test");
section1.setContent("test");
articles.add(section1);
Section section2 = new Section();
section2.setName("test");
section2.setContent("test");
articles.add(section2);
Section section3 = new Section();
section3.setName("test");
section3.setContent("test");
articles.add(section3);
session.save(article);
org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 3; expected: 1
it will pass through if only add one section,more sections will failed.
I guess hibernate doesn't use collection's size as expectedRowCount if the collection is not hibernate's implementation such as PersistentList , the expectedRowCount remains with last execution, here is saving master entity article.
|