Package com.impetus.client.couchdb.entities

Examples of com.impetus.client.couchdb.entities.PersonCouchOTM


        Set<AddressCouchOTM> addresses = new HashSet<AddressCouchOTM>();
        addresses.add(address1);
        addresses.add(address2);

        PersonCouchOTM person = new PersonCouchOTM();
        person.setPersonId("1");
        person.setPersonName("Kuldeep");
        person.setAddresses(addresses);

        em.persist(person);

        em = getNewEM();

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

        int counter = 0;
        for (AddressCouchOTM address : foundPerson.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++;
            }
        }

        Assert.assertEquals(2, counter);

        foundPerson.setPersonName("KK");

        em.merge(foundPerson);

        em = getNewEM();

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

        counter = 0;
        for (AddressCouchOTM address : foundPerson.getAddresses()) {
            if (address.getAddressId().equals("a")) {
                counter++;
                Assert.assertEquals("sector 11", address.getStreet());
            } else {
                Assert.assertEquals("b", address.getAddressId());
View Full Code Here


        Set<AddressCouchOTM> addresses = new HashSet<AddressCouchOTM>();
        addresses.add(address1);
        addresses.add(address2);

        PersonCouchOTM person = new PersonCouchOTM();
        person.setPersonId("1");
        person.setPersonName("Kuldeep");
        person.setAddresses(addresses);

        em.persist(person);

        PersonCouchOTM person1 = new PersonCouchOTM();
        person1.setPersonId("2");
        person1.setPersonName("KK");

        address1.setAddressId("a1");
        address1.setStreet("Sector a1");

        address2.setAddressId("a2");
        address2.setStreet("Sector a2");

        AddressCouchOTM address3 = new AddressCouchOTM();
        address3.setAddressId("a3");
        address3.setStreet("Sector a3");

        addresses = new HashSet<AddressCouchOTM>();
        addresses.add(address1);
        addresses.add(address2);
        addresses.add(address3);

        person1.setAddresses(addresses);

        em.persist(person1);

        em = getNewEM();
View Full Code Here

TOP

Related Classes of com.impetus.client.couchdb.entities.PersonCouchOTM

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.