Examples of PersonLazyRDBMSMTO


Examples of com.impetus.client.crud.entities.PersonLazyRDBMSMTO

    {
        AddressRDBMSMTO address = new AddressRDBMSMTO();
        address.setAddressId("a");
        address.setStreet("sector 11");

        PersonLazyRDBMSMTO person1 = new PersonLazyRDBMSMTO();
        person1.setPersonId("1");
        person1.setPersonName("Kuldeep");

        PersonLazyRDBMSMTO person2 = new PersonLazyRDBMSMTO();
        person2.setPersonId("2");
        person2.setPersonName("vivek");

        person1.setAddress(address);
        person2.setAddress(address);

        em.persist(person1);
        em.persist(person2);

        em = getNewEM();

        PersonLazyRDBMSMTO foundPerson1 = em.find(PersonLazyRDBMSMTO.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddress());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("Kuldeep", foundPerson1.getPersonName());
        Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());

        PersonLazyRDBMSMTO foundPerson2 = em.find(PersonLazyRDBMSMTO.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddress());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vivek", foundPerson2.getPersonName());
        Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());

        foundPerson1.setPersonName("KK");

        foundPerson2.setPersonName("vives");

        em.merge(foundPerson1);
        em.merge(foundPerson2);

        em = getNewEM();

        foundPerson1 = em.find(PersonLazyRDBMSMTO.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddress());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("KK", foundPerson1.getPersonName());
        Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());

        foundPerson2 = em.find(PersonLazyRDBMSMTO.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddress());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vives", foundPerson2.getPersonName());
        Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());

        List<PersonLazyRDBMSMTO> results = em.createQuery("select p from PersonLazyRDBMSMTO p").getResultList();
        Assert.assertNotNull(results);
        Assert.assertFalse(results.isEmpty());
        Assert.assertEquals(2, results.size());

        for (PersonLazyRDBMSMTO personLazyRDBMSMTO : results)
        {
            Assert.assertNotNull(personLazyRDBMSMTO);

            if (personLazyRDBMSMTO.getPersonId().equals("1"))
            {
                Assert.assertEquals("KK", personLazyRDBMSMTO.getPersonName());
            }
            else
            {
                Assert.assertEquals("2", personLazyRDBMSMTO.getPersonId());
                Assert.assertEquals("vives", personLazyRDBMSMTO.getPersonName());
            }
            Assert.assertNotNull(personLazyRDBMSMTO.getAddress());
            Assert.assertEquals("a", personLazyRDBMSMTO.getAddress().getAddressId());
            Assert.assertEquals("sector 11", personLazyRDBMSMTO.getAddress().getStreet());
        }

        results = em.createQuery("select p from PersonLazyRDBMSMTO p where p.personId = '1'").getResultList();
        Assert.assertNotNull(results);
        Assert.assertFalse(results.isEmpty());
        Assert.assertEquals(1, results.size());
       
        PersonLazyRDBMSMTO personLazyRDBMSMTO = results.get(0);

        Assert.assertNotNull(personLazyRDBMSMTO);
        Assert.assertEquals("KK", personLazyRDBMSMTO.getPersonName());
        Assert.assertNotNull(personLazyRDBMSMTO.getAddress());
        Assert.assertEquals("a", personLazyRDBMSMTO.getAddress().getAddressId());
        Assert.assertEquals("sector 11", personLazyRDBMSMTO.getAddress().getStreet());

        em.remove(foundPerson1);
        em.remove(foundPerson2);

        foundPerson1 = em.find(PersonLazyRDBMSMTO.class, "1");
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.