import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.transaction.annotation.Transactional;

public class JPAI_Sample {

    @Transactional
    private void writeData() {
        
    }
    
    @Transactional
    public void writeGoodData() {
    }
    
    private void badWrite() {
        writeGoodData();
    }
    
    @Entity
    @Table(name = "MY_ENTITY")
    public static class MyEntity {
        
        public Integer id;
        
        @Id
        @SequenceGenerator(name = "MY_ENTITY_SEQ", sequenceName = "MY_ENTITY_SEQ", allocationSize = 100)
        @GeneratedValue(generator = "MY_ENTITY_SEQ")
        public Integer getId() {
            return id;
        }
        
        public void setId(Integer id) {
            this.id = id;
        }
        
        @Override
        public int hashCode() {
            return id.hashCode();
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof MyEntity)) {
                return false;
            }
            
            MyEntity that = (MyEntity) o;
            if (id == null) {
                return that.id == null;
            }
            
            return id.equals(that.id);
        }
    }
}

@@ -1,28 +1,123 @@
+import java.util.List;%0A%0Aimport javax.persistence.CascadeType;%0Aimport javax.persistence.Column;%0A
 import javax.persistence.Ent
@@ -121,16 +121,52 @@
 Entity;%0A
+import javax.persistence.FetchType;%0A
 import j
@@ -227,16 +227,125 @@
 nce.Id;%0A
+import javax.persistence.JoinColumn;%0Aimport javax.persistence.ManyToOne;%0Aimport javax.persistence.OneToMany;%0A
 import j
@@ -795,37 +795,38 @@
       %0A        p
-ublic
+rivate
  Integer id;%0A   
@@ -818,24 +818,69 @@
 Integer id;%0A
+        private List%3CSubEntity%3E subEntities;%0A
         %0A   
@@ -1046,16 +1046,78 @@
 Y_SEQ%22)%0A
+        @Column(name = %22ID%22, nullable = false, unique = true)%0A
         
@@ -1250,32 +1250,375 @@
  = id;%0A        %7D
+%0A%0A        @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy = %22myEntity%22, targetEntity = MyEntity.class)%0A        public List%3CSubEntity%3E getSubEntities() %7B%0A            return subEntities;%0A        %7D%0A        %0A        public void setSubEntities(List%3CSubEntity%3E subEntities) %7B%0A            this.subEntities = subEntities;%0A        %7D
 %0A        %0A      
@@ -2061,10 +2061,946 @@
 %7D%0A    %7D%0A
+    %0A    @Entity%0A    @Table(name = %22SUB_ENTITY%22)%0A    public static class SubEntity %7B%0A        %0A        public Integer subId;%0A        public MyEntity myEntity;%0A        %0A        @Id%0A        @SequenceGenerator(name = %22SUB_ENTITY_SEQ%22, sequenceName = %22SUB_ENTITY_SEQ%22, allocationSize = 100)%0A        @GeneratedValue(generator = %22SUB_ENTITY_SEQ%22)%0A        @Column(name = %22SUB_ID%22, nullable = false, unique = true)%0A        public Integer getSubId() %7B%0A            return subId;%0A        %7D%0A        %0A        public void setSubId(Integer subId) %7B%0A            this.subId = subId;%0A        %7D%0A%0A        @JoinColumn(name = %22ID%22, referencedColumnName = %22ID%22, nullable = false)%0A        @ManyToOne(fetch = FetchType.EAGER, targetEntity = MyEntity.class)%0A        public MyEntity getMyEntity() %7B%0A            return myEntity;%0A        %7D%0A%0A        public void setMyEntity(MyEntity myEntity) %7B%0A            this.myEntity = myEntity;%0A        %7D%0A        %0A        %0A    %7D%0A
 %7D%0A

add sample pattern for @OneToMany and EAGER