Examples of LazyEmployee


Examples of com.mysql.clusterj.jpatest.model.LazyEmployee

    public void test() {
        removeAll(LazyEmployee.class);
        em.getTransaction().begin();
        for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
            LazyEmployee e = createLazyEmployee(i);
            em.persist(e);
        }
        em.getTransaction().commit();
        em.clear();
        em.getTransaction().begin();
        Query query = em.createQuery("select e from LazyEmployee e where e.id = :id");
        for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
            query.setParameter("id", i);
            LazyEmployee e = (LazyEmployee)query.getSingleResult();
            int id = e.getId();
            int magic = e.getMagic();
            // name and age are lazily loaded
            final int age;
            final String name;
            if (0 == i%2) {
                // age and name are loaded separately because age has no load fetch group
                age = e.getAge();
                name = e.getName();
            } else {
                // age and name are loaded together because name's load fetch group includes age
                name = e.getName();
                age = e.getAge();
            }
            String result = new String("Lazy Employee " + id + " magic: " + magic + " age: " + age + " name: " + name);
//            System.out.println(result);
        }
        em.getTransaction().commit();
View Full Code Here

Examples of com.mysql.clusterj.jpatest.model.LazyEmployee

        }
        em.getTransaction().commit();
    }

    private LazyEmployee createLazyEmployee(int i) {
        LazyEmployee lazy = new LazyEmployee();
        lazy.setId(i);
        lazy.setAge(i);
        lazy.setName("LazyEmployee " + i);
        lazy.setMagic(i);
        return lazy;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.