Package com.avaje.ebean

Examples of com.avaje.ebean.BeanState


 
  @Test
  public void testListInitialisation() {
   
    Customer customer = new Customer();
    BeanState beanState = Ebean.getBeanState(customer);
    if (beanState != null) {
      List<Order> orders = customer.getOrders();
      Assert.assertNotNull(orders);
    }
   
View Full Code Here


  public void test() {
   
    ResetBasicData.reset();
    Order order = Ebean.getReference(Order.class, 1);

    BeanState beanState = Ebean.getBeanState(order);
    Set<String> loadedProps = beanState.getLoadedProps();
   
    Assert.assertEquals(1, loadedProps.size());
    Assert.assertTrue(beanState.isReference());

    // read the status invokes lazy loading
    order.getStatus();
   
    Assert.assertFalse(beanState.isReference());

  }
View Full Code Here

    Customer customer = (Customer)descriptor.jsonRead(parser, null);
   
    Assert.assertEquals(Integer.valueOf(123), customer.getId());
    Assert.assertEquals("Hello rob", customer.getName());
   
    BeanState beanState = Ebean.getBeanState(customer);
    Set<String> loadedProps = beanState.getLoadedProps();
   
    Assert.assertEquals(2, loadedProps.size());
    Assert.assertTrue(loadedProps.contains("id"));
    Assert.assertTrue(loadedProps.contains("name"));
   
View Full Code Here

   
    JsonContext jsonContext = Ebean.json();

    Product product = Ebean.getReference(Product.class, 1);

    BeanState beanState0 = Ebean.getBeanState(product);
    if (!beanState0.isReference()) {
      // got a cached value from beanCache

    } else {

      String jsonString = jsonContext.toJson(product);
      System.out.println(jsonString);

      Product refProd = jsonContext.toBean(Product.class, jsonString);

      BeanDescriptor<Product> prodDesc = server.getBeanDescriptor(Product.class);
      EntityBean eb = (EntityBean)refProd;
      prodDesc.isReference(eb._ebean_getIntercept());
     
      BeanState beanState = Ebean.getBeanState(refProd);
      Assert.assertTrue(beanState.isNew());
     
      String name = refProd.getName();
      Assert.assertNull(name);

      // Set to be 'loaded' to invoke lazy loading
      beanState.setLoaded();
      String name2 = refProd.getName();
      Assert.assertNotNull(name2);

    }
View Full Code Here

TOP

Related Classes of com.avaje.ebean.BeanState

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.