// Path: hibernate4-memcached-example/src/main/java/kr/pe/kwonnam/hibernate4memcached/example/entity/Employee.java
// @Entity
// @Table(name = "employees")
// @Cache(region = "employees", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
// public class Employee implements Serializable {
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private Long id;
// 
//     @Column(name = "name", length = 32, nullable = false)
//     private String name;
// 
//     @Column(name = "position", length = 32, nullable = false)
//     private String position;
// 
//     @OneToMany
//     @JoinColumn(name = "boss_id", referencedColumnName = "id", nullable = true)
//     @org.hibernate.annotations.OrderBy(clause = "name")
//     @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
//     private List<Employee> workers;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getPosition() {
//         return position;
//     }
// 
//     public void setPosition(String position) {
//         this.position = position;
//     }
// 
//     public List<Employee> getWorkers() {
//         return workers;
//     }
// 
//     public void setWorkers(List<Employee> workers) {
//         this.workers = workers;
//     }
// 
//     public void addWorker(Employee worker) {
//         if (workers == null) {
//             workers = new ArrayList<Employee>();
//         }
// 
//         workers.add(worker);
//     }
// 
//     @Override
//     public String toString() {
//         return "Employee{" +
//                 "id=" + id +
//                 ", name='" + name + '\'' +
//                 ", position='" + position + '\'' +
//                 ", workers=" + workers +
//                 '}';
//     }
// }


import kr.pe.kwonnam.hibernate4memcached.example.entity.Employee;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import static org.fest.assertions.api.Assertions.assertThat;
package kr.pe.kwonnam.hibernate4memcached.example;




/**
 * @author KwonNam Son (kwon37xi@gmail.com)
 */
public class NonstrictReadWriteSelfRelationTest {
    private Logger log = LoggerFactory.getLogger(NonstrictReadWriteSelfRelationTest.class);

    @Before
    public void setUp() throws Exception {
        EntityTestUtils.init();
    }

    @After
    public void tearDown() throws Exception {
        EntityTestUtils.destroy();
    }

    @Test
    public void selfRelation() throws Exception {
        log.debug("#### Load data");

        EntityManager em = EntityTestUtils.start();
        EntityTransaction transaction = em.getTransaction();
        transaction.begin();

// Path: hibernate4-memcached-example/src/main/java/kr/pe/kwonnam/hibernate4memcached/example/entity/Employee.java
// @Entity
// @Table(name = "employees")
// @Cache(region = "employees", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
// public class Employee implements Serializable {
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private Long id;
// 
//     @Column(name = "name", length = 32, nullable = false)
//     private String name;
// 
//     @Column(name = "position", length = 32, nullable = false)
//     private String position;
// 
//     @OneToMany
//     @JoinColumn(name = "boss_id", referencedColumnName = "id", nullable = true)
//     @org.hibernate.annotations.OrderBy(clause = "name")
//     @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
//     private List<Employee> workers;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getPosition() {
//         return position;
//     }
// 
//     public void setPosition(String position) {
//         this.position = position;
//     }
// 
//     public List<Employee> getWorkers() {
//         return workers;
//     }
// 
//     public void setWorkers(List<Employee> workers) {
//         this.workers = workers;
//     }
// 
//     public void addWorker(Employee worker) {
//         if (workers == null) {
//             workers = new ArrayList<Employee>();
//         }
// 
//         workers.add(worker);
//     }
// 
//     @Override
//     public String toString() {
//         return "Employee{" +
//                 "id=" + id +
//                 ", name='" + name + '\'' +
//                 ", position='" + position + '\'' +
//                 ", workers=" + workers +
//                 '}';
//     }
// }


// Path: hibernate4-memcached-example/src/test/java/kr/pe/kwonnam/hibernate4memcached/example/NonstrictReadWriteSelfRelationTest.java
import kr.pe.kwonnam.hibernate4memcached.example.entity.Employee;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import static org.fest.assertions.api.Assertions.assertThat;

package kr.pe.kwonnam.hibernate4memcached.example;




/**
 * @author KwonNam Son (kwon37xi@gmail.com)
 */
public class NonstrictReadWriteSelfRelationTest {
    private Logger log = LoggerFactory.getLogger(NonstrictReadWriteSelfRelationTest.class);

    @Before
    public void setUp() throws Exception {
        EntityTestUtils.init();
    }

    @After
    public void tearDown() throws Exception {
        EntityTestUtils.destroy();
    }

    @Test
    public void selfRelation() throws Exception {
        log.debug("#### Load data");

        EntityManager em = EntityTestUtils.start();
        EntityTransaction transaction = em.getTransaction();
        transaction.begin();

        Employee boss = new Employee();