Package com.impetus.kundera.polyglot.entities

Examples of com.impetus.kundera.polyglot.entities.PersonUMM


    @Test
    public void testManyToMany() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
            IllegalAccessException
    {
        PersonUMM person = new PersonUMM();
        person.setPersonId("person1");
        person.setPersonName("personName");

        AddressUMM address = new AddressUMM();
        address.setAddressId("addr1");
        address.setStreet("mtmstreet");

        Set<AddressUMM> addresses = new HashSet<AddressUMM>();
        addresses.add(address);
        person.setAddresses(addresses);

        em.persist(person);

        PersistenceDelegator delegator = CoreTestUtilities.getDelegator(em);

        Map<String, Object> relationMap = new HashMap<String, Object>();
        relationMap.put("ADDRESS_ID", "addr1");

        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(
                ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), PersonUMM.class);

        CoreTestEntityReader reader = new CoreTestEntityReader(kunderaMetadata);

        person.setAddresses(null);

        reader.recursivelyFindEntities(person, relationMap, metadata, delegator, false);

        Assert.assertNotNull(person.getAddresses());

        Assert.assertTrue(ProxyHelper.isKunderaProxyCollection(person.getAddresses()));

        reader.recursivelyFindEntities(person, relationMap, metadata, delegator, true);

        Assert.assertTrue(person.getAddresses().isEmpty()); // code to fetch
                                                            // from join table
                                                            // data in dummy
                                                            // client is
                                                            // missing.
View Full Code Here


    }

    @Override
    protected void insert()
    {
        PersonUMM person1 = new PersonUMM();
        person1.setPersonId("unimanytomany_1");
        person1.setPersonName("Amresh");

        PersonUMM person2 = new PersonUMM();
        person2.setPersonId("unimanytomany_2");
        person2.setPersonName("Vivek");

        AddressUMM address1 = new AddressUMM();
        address1.setAddressId("unimanytomany_a");
        address1.setStreet("AAAAAAAAAAAAA");

        AddressUMM address2 = new AddressUMM();
        address2.setAddressId("unimanytomany_b");
        address2.setStreet("BBBBBBBBBBBBBBB");

        AddressUMM address3 = new AddressUMM();
        address3.setAddressId("unimanytomany_c");
        address3.setStreet("CCCCCCCCCCC");

        Set<AddressUMM> person1Addresses = new HashSet<AddressUMM>();
        Set<AddressUMM> person2Addresses = new HashSet<AddressUMM>();

        person1Addresses.add(address1);
        person1Addresses.add(address2);

        person2Addresses.add(address2);
        person2Addresses.add(address3);

        person1.setAddresses(person1Addresses);
        person2.setAddresses(person2Addresses);

        Set<PersonUMM> persons = new HashSet<PersonUMM>();
        persons.add(person1);
        persons.add(person2);
View Full Code Here

    @Override
    protected void find()
    {

        PersonUMM person1 = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_1");
        assertPerson1(person1);

        PersonUMM person2 = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_2");
        assertPerson2(person2);
    }
View Full Code Here

    @Override
    protected void findPersonByIdColumn()
    {
        // Find Person 1
        PersonUMM p1 = (PersonUMM) dao.findPersonByIdColumn(PersonUMM.class, "unimanytomany_1");
        assertPerson1(p1);

        // Find Person 2
        PersonUMM p2 = (PersonUMM) dao.findPersonByIdColumn(PersonUMM.class, "unimanytomany_2");
        assertPerson2(p2);
    }
View Full Code Here

    }

    @Override
    protected void update()
    {
        PersonUMM p1 = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_1");
        Assert.assertNotNull(p1);
        p1.setPersonName("Saurabh");
        Assert.assertEquals(2, p1.getAddresses().size());
        for (AddressUMM address : p1.getAddresses())
        {
            address.setStreet("Brand New Street");
        }
        dao.merge(p1);
        PersonUMM p1AfterMerge = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_1");
        Assert.assertNotNull(p1AfterMerge);
        Assert.assertEquals("Saurabh", p1AfterMerge.getPersonName());
        Assert.assertEquals(2, p1AfterMerge.getAddresses().size());
        for (AddressUMM address : p1AfterMerge.getAddresses())
        {
            Assert.assertEquals("Brand New Street", address.getStreet());
        }

        PersonUMM p2 = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_2");
        Assert.assertNotNull(p2);
        Assert.assertEquals(2, p2.getAddresses().size());
        p2.setPersonName("Vijay");
        for (AddressUMM address : p2.getAddresses())
        {
            address.setStreet("Brand New Street");
        }
        dao.merge(p2);
        PersonUMM p2AfterMerge = (PersonUMM) dao.findPerson(PersonUMM.class, "unimanytomany_2");
        Assert.assertNotNull(p2AfterMerge);
        Assert.assertEquals("Vijay", p2AfterMerge.getPersonName());
        Assert.assertEquals(2, p2AfterMerge.getAddresses().size());
        for (AddressUMM address : p2AfterMerge.getAddresses())
        {
            Assert.assertEquals("Brand New Street", address.getStreet());
        }
    }
View Full Code Here

    @Override
    protected void remove()
    {
        dao.remove("unimanytomany_1", PersonUMM.class);
        PersonUMM person1AfterRemoval = (PersonUMM) dao.findPerson(PersonUMM.class,
                "unimanytomany_1");
        Assert.assertNull(person1AfterRemoval);

        dao.remove("unimanytomany_2", PersonUMM.class);
        PersonUMM person2AfterRemoval = (PersonUMM) dao.findPerson(PersonUMM.class,
                "unimanytomany_2");
        Assert.assertNull(person2AfterRemoval);
    }
View Full Code Here

TOP

Related Classes of com.impetus.kundera.polyglot.entities.PersonUMM

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.