Package com.impetus.client.oraclenosql.entities

Examples of com.impetus.client.oraclenosql.entities.PersonOracleNoSqlMTM


        Set<AddressOracleNoSqlMTM> addresses2 = new HashSet<AddressOracleNoSqlMTM>();
        addresses2.add(address2);
        addresses2.add(address3);

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

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

        person1.setAddresses(addresses1);
        person2.setAddresses(addresses2);

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

        em = getNewEM();

        PersonOracleNoSqlMTM foundPerson1 = em.find(PersonOracleNoSqlMTM.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddresses());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("Kuldeep", foundPerson1.getPersonName());

        int counter = 0;
        for (AddressOracleNoSqlMTM address : foundPerson1.getAddresses()) {
            if (address.getAddressId().equals("a")) {
                counter++;
                Assert.assertEquals("sector 11", address.getStreet());
            } else {
                Assert.assertEquals("b", address.getAddressId());
                Assert.assertEquals("sector 12", address.getStreet());
                counter++;
            }
        }

        PersonOracleNoSqlMTM foundPerson2 = em.find(PersonOracleNoSqlMTM.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddresses());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vivek", foundPerson2.getPersonName());

        counter = 0;
        for (AddressOracleNoSqlMTM address : foundPerson2.getAddresses()) {
            if (address.getAddressId().equals("b")) {
                counter++;
                Assert.assertEquals("sector 12", address.getStreet());
            } else {
                Assert.assertEquals("c", address.getAddressId());
                Assert.assertEquals("sector 13", address.getStreet());
                counter++;
            }
        }

        foundPerson1.setPersonName("KK");

        foundPerson2.setPersonName("vives");

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

        em = getNewEM();

        foundPerson1 = em.find(PersonOracleNoSqlMTM.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddresses());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("KK", foundPerson1.getPersonName());

        counter = 0;
        for (AddressOracleNoSqlMTM address : foundPerson1.getAddresses()) {
            if (address.getAddressId().equals("a")) {
                counter++;
                Assert.assertEquals("sector 11", address.getStreet());
            } else {
                Assert.assertEquals("b", address.getAddressId());
                Assert.assertEquals("sector 12", address.getStreet());
                counter++;
            }
        }

        foundPerson2 = em.find(PersonOracleNoSqlMTM.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddresses());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vives", foundPerson2.getPersonName());

        counter = 0;
        for (AddressOracleNoSqlMTM address : foundPerson2.getAddresses()) {
            if (address.getAddressId().equals("b")) {
                counter++;
                Assert.assertEquals("sector 12", address.getStreet());
            } else {
                Assert.assertEquals("c", address.getAddressId());
View Full Code Here


        Set<AddressOracleNoSqlMTM> addresses2 = new HashSet<AddressOracleNoSqlMTM>();
        addresses2.add(address2);
        addresses2.add(address3);

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

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

        person1.setAddresses(addresses1);
        person2.setAddresses(addresses2);

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

        em = getNewEM();

        String personsQueryStr = " Select p from PersonOracleNoSqlMTM p";
        Query personsQuery = em.createQuery(personsQueryStr);
        List<PersonOracleNoSqlMTM> allPersons = personsQuery.getResultList();
        Assert.assertNotNull(allPersons);

        for (PersonOracleNoSqlMTM foundPerson : allPersons) {
            Assert.assertNotNull(foundPerson);
            Assert.assertNotNull(foundPerson.getAddresses());
            Assert.assertEquals(2, foundPerson.getAddresses().size());
           
            if (foundPerson.getPersonId().equals("1")) {

               
                Assert.assertEquals("1", foundPerson.getPersonId());
                Assert.assertEquals("Kuldeep", foundPerson.getPersonName());

                for (AddressOracleNoSqlMTM address : foundPerson.getAddresses()) {
                    if (address.getAddressId().equals("a")) {

                        Assert.assertEquals("sector 11", address.getStreet());
                    } else {
                        Assert.assertEquals("b", address.getAddressId());
                        Assert.assertEquals("sector 12", address.getStreet());

                    }
                }
            } else if (foundPerson.getPersonId().equals("2")) {

 
                Assert.assertEquals("2", foundPerson.getPersonId());
                Assert.assertEquals("vivek", foundPerson.getPersonName());

                for (AddressOracleNoSqlMTM address : foundPerson.getAddresses()) {
                    if (address.getAddressId().equals("b")) {

                        Assert.assertEquals("sector 12", address.getStreet());
                    } else {
                        Assert.assertEquals("c", address.getAddressId());
                        Assert.assertEquals("sector 13", address.getStreet());

                    }
                }
            }
         
        }
        em.remove(allPersons.get(0));
        em.remove(allPersons.get(1));
        PersonOracleNoSqlMTM  foundPerson1 = em.find(PersonOracleNoSqlMTM.class, allPersons.get(0).getPersonId());
        PersonOracleNoSqlMTM  foundPerson2 = em.find(PersonOracleNoSqlMTM.class, allPersons.get(1).getPersonId());
        Assert.assertNull(foundPerson1);
        Assert.assertNull(foundPerson2);

    }
View Full Code Here

TOP

Related Classes of com.impetus.client.oraclenosql.entities.PersonOracleNoSqlMTM

Copyright © 2018 www.massapicom. 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.