Package com.acme.jpa.model

Examples of com.acme.jpa.model.Record


    * the entity is retrieved from a transaction-scoped persistence context owned by that EJB.
    */
   @Test
   public void entity_should_not_be_managed_by_transaction_scoped_pc_outside_active_ejb()
   {
      Record record = helper.retrieveById(Record.class, idOfFirstRecord);
      assertFalse(helper.isManaging(record));
   }
View Full Code Here


    * that EJB.
    */
   @Test
   public void lazy_load_should_succeed_outside_of_active_ejb_with_extended_pc()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord);
      int numLineItemsExpected = 1;
      int numLineItemsActual = 0;
      try
      {
         numLineItemsActual = record.getLineItems().size();
      }
      catch (Exception e)
      {
      }
      assertEquals(numLineItemsExpected, numLineItemsActual);
View Full Code Here

    * available at this point.
    */
   @Test
   public void lazy_load_should_fail_outside_of_removed_ejb()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord);
      repository.close();
      // Some JPA providers (EclipseLink) allow LAZY relationships to be accessed after session is closed
      int numLineItemsExpected = helper.isLazyLoadingPermittedOnClosedSession() ? 1 : 0;
      int numLineItemsActual = 0;
      try
      {
         numLineItemsActual = record.getLineItems().size();
      }
      catch (Exception e)
      {
      }
      assertEquals(numLineItemsExpected, numLineItemsActual);
View Full Code Here

    * accessed after the session is closed.
    */
   @Test
   public void lazy_load_should_fail_outside_transaction_when_entity_retrieved_by_transaction_scoped_pc()
   {
      Record record = helper.retrieveById(Record.class, idOfFirstRecord);
      assertFalse(helper.isManaging(record));
      // Some JPA providers (e.g., EclipseLink) allow lazy relationships to be accessed after session is closed
      int numLineItemsExpected = helper.isLazyLoadingPermittedOnClosedSession() ? 1 : 0;
      int numLineItemsActual = 0;
      try
      {
         numLineItemsActual = record.getLineItems().size();
      }
      catch (Exception e)
      {
      }
      // verify the line items can't be fetched outside of EJB
View Full Code Here

    * that is managing the entity.
    */
   @Test
   public void dirty_change_should_be_flushed_by_extended_pc_when_transactional_method_on_same_ejb_called()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord);
      assertTrue(repository.isManaging(record));
      String name = record.getName();
      record.setName(name + "-renamed");
      repository.update(record);
      List<Record> results = repository.retrieveByQuery(Record.class, "select r from Record r where r.name = ?1", name + "-renamed");
      assertEquals(1, results.size());
   }
View Full Code Here

    * managing the entity.
    */
   @Test
   public void dirty_change_should_be_flushed_by_extended_pc_when_transactional_method_on_another_ejb_called()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord);
      assertTrue(repository.isManaging(record));
      assertFalse(helper.isManaging(record));
      String name = record.getName();
      record.setName(name + "-renamed");
      helper.transact();
      List<Record> results = repository.retrieveByQuery(Record.class, "select r from Record r where r.name = ?1", name + "-renamed");
      assertEquals(1, results.size());
   }
View Full Code Here

    * not matter in this case.
    */
   @Test
   public void lazy_load_should_succeed_within_transaction()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord, new EntityInitializer<Record>()
      {
         @Override
         public Record initialize(Record record)
         {
            record.getLineItems().size();
            return record;
         }
      });
      int numLineItemsExpected = 1;
      assertEquals(numLineItemsExpected, record.getLineItems().size());
   }
View Full Code Here

    * the entity is retrieved from an extended persistence context owned by that EJB.
    */
   @Test
   public void entity_should_be_managed_by_extended_pc_outside_active_ejb()
   {
      Record record = repository.retrieveById(Record.class, idOfFirstRecord);
      assertTrue(repository.isManaging(record));
   }
View Full Code Here

      if (clear)
      {
         em.createQuery("delete from Record").executeUpdate();
      }
      List<Record> records = new ArrayList<Record>();
      Record a = new Record("Record A");
      LineItem l1 = new LineItem(new BigDecimal(50));
      a.addLineItem(l1);
      em.persist(a);
      records.add(a);
      return records;
   }
View Full Code Here

TOP

Related Classes of com.acme.jpa.model.Record

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.