Package org.hibernate.test.cache.infinispan.functional

Examples of org.hibernate.test.cache.infinispan.functional.Contact


         Session session = sessionFactory.getCurrentSession();
         Customer customer = new Customer();
         customer.setName("JBoss");
         Set<Contact> contacts = new HashSet<Contact>();

         Contact kabir = new Contact();
         kabir.setCustomer(customer);
         kabir.setName("Kabir");
         kabir.setTlf("1111");
         contacts.add(kabir);

         Contact bill = new Contact();
         bill.setCustomer(customer);
         bill.setName("Bill");
         bill.setTlf("2222");
         contacts.add(bill);

         customer.setContacts(contacts);

         session.save(customer);
         tm.commit();

         IdContainer ids = new IdContainer();
         ids.customerId = customer.getId();
         Set contactIds = new HashSet();
         contactIds.add(kabir.getId());
         contactIds.add(bill.getId());
         ids.contactIds = contactIds;

         return ids;
      } catch (Exception e) {
         log.error("Caught exception creating customer", e);
View Full Code Here


         ids.customerId = customer.getId();
         Set<Contact> contacts = customer.getContacts();
         for (Contact c : contacts) {
            contactIds.add(c.getId());
         }
         Contact contact = contacts.iterator().next();
         contacts.remove(contact);
         contactIds.remove(contact.getId());
         ids.contactIds = contactIds;
         contact.setCustomer(null);
        
         session.save(customer);
         tm.commit();
         return ids;
      } catch (Exception e) {
View Full Code Here

         }

         updateContacts("Kabir", "Updated");
         assertEquals(0, contactSlcs.getElementCountInMemory());
         for (Integer id : jbContacts) {
            Contact contact = getContact(id);
            assertNotNull("JBoss contact " + id + " exists", contact);
            String expected = ("Kabir".equals(contact.getName())) ? "Updated" : "2222";
            assertEquals("JBoss contact " + id + " has correct TLF", expected, contact.getTlf());
         }

         List<Integer> updated = getContactsByTLF("Updated");
         assertNotNull("Got updated contacts", updated);
         assertEquals("Updated contacts", 5, updated.size());

         updateContactsWithOneManual("Kabir", "UpdatedAgain");
         assertEquals(contactSlcs.getElementCountInMemory(), 0);
         for (Integer id : jbContacts) {
            Contact contact = getContact(id);
            assertNotNull("JBoss contact " + id + " exists", contact);
            String expected = ("Kabir".equals(contact.getName())) ? "UpdatedAgain" : "2222";
            assertEquals("JBoss contact " + id + " has correct TLF", expected, contact.getTlf());
         }

         updated = getContactsByTLF("UpdatedAgain");
         assertNotNull("Got updated contacts", updated);
         assertEquals("Updated contacts", 5, updated.size());
View Full Code Here

   public Contact getContact(Integer id) throws Exception {
      tm.begin();
      try {
         Session session = getSessions().getCurrentSession();
         Contact contact = (Contact) session.get(Contact.class, id);
         return contact;
      } catch (Exception e) {
         log.error("Unable to get contact", e);
         tm.setRollbackOnly();
         throw e;
View Full Code Here

      try {
         Customer customer = new Customer();
         customer.setName((id % 2 == 0) ? "JBoss" : "Red Hat");
         Set<Contact> contacts = new HashSet<Contact>();

         Contact kabir = new Contact();
         kabir.setCustomer(customer);
         kabir.setName("Kabir");
         kabir.setTlf("1111");
         contacts.add(kabir);

         Contact bill = new Contact();
         bill.setCustomer(customer);
         bill.setName("Bill");
         bill.setTlf("2222");
         contacts.add(bill);

         customer.setContacts(contacts);

         Session s = openSession();
View Full Code Here

      }

      updateContacts( "Kabir", "Updated" );
      assertEquals( 0, contactSlcs.getElementCountInMemory() );
      for ( Integer id : jbContacts ) {
        Contact contact = getContact( id );
        assertNotNull( "JBoss contact " + id + " exists", contact );
        String expected = ("Kabir".equals( contact.getName() )) ? "Updated" : "2222";
        assertEquals( "JBoss contact " + id + " has correct TLF", expected, contact.getTlf() );
      }

      List<Integer> updated = getContactsByTLF( "Updated" );
      assertNotNull( "Got updated contacts", updated );
      assertEquals( "Updated contacts", 5, updated.size() );

      updateContactsWithOneManual( "Kabir", "UpdatedAgain" );
      assertEquals( contactSlcs.getElementCountInMemory(), 0 );
      for ( Integer id : jbContacts ) {
        Contact contact = getContact( id );
        assertNotNull( "JBoss contact " + id + " exists", contact );
        String expected = ("Kabir".equals( contact.getName() )) ? "UpdatedAgain" : "2222";
        assertEquals( "JBoss contact " + id + " has correct TLF", expected, contact.getTlf() );
      }

      updated = getContactsByTLF( "UpdatedAgain" );
      assertNotNull( "Got updated contacts", updated );
      assertEquals( "Updated contacts", 5, updated.size() );
View Full Code Here

    try {
      Customer customer = new Customer();
      customer.setName( (id % 2 == 0) ? "JBoss" : "Red Hat" );
      Set<Contact> contacts = new HashSet<Contact>();

      Contact kabir = new Contact();
      kabir.setCustomer( customer );
      kabir.setName( "Kabir" );
      kabir.setTlf( "1111" );
      contacts.add( kabir );

      Contact bill = new Contact();
      bill.setCustomer( customer );
      bill.setName( "Bill" );
      bill.setTlf( "2222" );
      contacts.add( bill );

      customer.setContacts( contacts );

      Session s = openSession();
View Full Code Here

      Session session = sessionFactory.getCurrentSession();
      Customer customer = new Customer();
      customer.setName( "JBoss" );
      Set<Contact> contacts = new HashSet<Contact>();

      Contact kabir = new Contact();
      kabir.setCustomer( customer );
      kabir.setName( "Kabir" );
      kabir.setTlf( "1111" );
      contacts.add( kabir );

      Contact bill = new Contact();
      bill.setCustomer( customer );
      bill.setName( "Bill" );
      bill.setTlf( "2222" );
      contacts.add( bill );

      customer.setContacts( contacts );

      session.save( customer );
      tm.commit();

      IdContainer ids = new IdContainer();
      ids.customerId = customer.getId();
      Set contactIds = new HashSet();
      contactIds.add( kabir.getId() );
      contactIds.add( bill.getId() );
      ids.contactIds = contactIds;

      return ids;
    }
    catch (Exception e) {
View Full Code Here

      ids.customerId = customer.getId();
      Set<Contact> contacts = customer.getContacts();
      for ( Contact c : contacts ) {
        contactIds.add( c.getId() );
      }
      Contact contact = contacts.iterator().next();
      contacts.remove( contact );
      contactIds.remove( contact.getId() );
      ids.contactIds = contactIds;
      contact.setCustomer( null );

      session.save( customer );
      tm.commit();
      return ids;
    }
View Full Code Here

      }

      updateContacts( "Kabir", "Updated" );
      assertEquals( 0, contactSlcs.getElementCountInMemory() );
      for ( Integer id : jbContacts ) {
        Contact contact = getContact( id );
        assertNotNull( "JBoss contact " + id + " exists", contact );
        String expected = ("Kabir".equals( contact.getName() )) ? "Updated" : "2222";
        assertEquals( "JBoss contact " + id + " has correct TLF", expected, contact.getTlf() );
      }

      List<Integer> updated = getContactsByTLF( "Updated" );
      assertNotNull( "Got updated contacts", updated );
      assertEquals( "Updated contacts", 5, updated.size() );

      updateContactsWithOneManual( "Kabir", "UpdatedAgain" );
      assertEquals( contactSlcs.getElementCountInMemory(), 0 );
      for ( Integer id : jbContacts ) {
        Contact contact = getContact( id );
        assertNotNull( "JBoss contact " + id + " exists", contact );
        String expected = ("Kabir".equals( contact.getName() )) ? "UpdatedAgain" : "2222";
        assertEquals( "JBoss contact " + id + " has correct TLF", expected, contact.getTlf() );
      }

      updated = getContactsByTLF( "UpdatedAgain" );
      assertNotNull( "Got updated contacts", updated );
      assertEquals( "Updated contacts", 5, updated.size() );
View Full Code Here

TOP

Related Classes of org.hibernate.test.cache.infinispan.functional.Contact

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.