@@ -0,0 +1,2224 @@
+package com.vladmihalcea.hibernate.masterclass.laboratory.flushing;%0A%0Aimport com.vladmihalcea.hibernate.masterclass.laboratory.util.AbstractIntegrationTest;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * SqlCascadeDeleteBatchingTest - Test to check the SQL cascade delete%0A *%0A * @author Vlad Mihalcea%0A */%0Apublic class MergeWithTransientOnInverseSideTest extends AbstractIntegrationTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D%7B%0A            Post.class,%0A            Comment.class%0A        %7D;%0A    %7D%0A%0A    @Test%0A    public void testMerge() %7B%0A%0A        final Post post = doInTransaction(session -%3E %7B%0A            Post _post = new Post(%22Post%22);%0A            session.persist(_post);%0A            return _post;%0A        %7D);%0A%0A        doInTransaction(session -%3E %7B%0A            post.getComments().add(new Comment());%0A            session.merge(post);%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Post%22)%0A    public static class Post %7B%0A%0A        @Id%0A        @GeneratedValue%0A        private Long id;%0A%0A        private String title;%0A%0A        @Version%0A        private int version;%0A%0A        private Post() %7B%0A        %7D%0A%0A        public Post(String title) %7B%0A            this.title = title;%0A        %7D%0A%0A        @OneToMany(mappedBy = %22post%22)%0A        private List%3CComment%3E comments = new ArrayList%3C%3E();%0A%0A        public void setTitle(String title) %7B%0A            this.title = title;%0A        %7D%0A%0A        public List%3CComment%3E getComments() %7B%0A            return comments;%0A        %7D%0A%0A        public void addComment(Comment comment) %7B%0A            comments.add(comment);%0A            comment.setPost(this);%0A        %7D%0A    %7D%0A%0A    @Entity(name = %22Comment%22)%0A    public static class Comment %7B%0A%0A        @Id%0A        @GeneratedValue%0A        private Long id;%0A%0A        @ManyToOne(fetch = FetchType.LAZY)%0A        private Post post;%0A%0A        @Version%0A        private int version;%0A%0A        private Comment() %7B%7D%0A%0A        public Comment(String review) %7B%0A            this.review = review;%0A        %7D%0A%0A        private String review;%0A%0A        public Long getId() %7B%0A            return id;%0A        %7D%0A%0A        public void setPost(Post post) %7B%0A            this.post = post;%0A        %7D%0A    %7D%0A%7D%0A

Add test for http://stackoverflow.com/questions/29283301/why-does-merge-attempt-to-persist-validate-entities-in-an-inverse-onetomany-c