Package com.avaje.tests.model.basic

Examples of com.avaje.tests.model.basic.FeatureDescription


public class TestL2CacheWithSharedBean extends BaseTestCase {

  @Test
  public void test() {

    FeatureDescription f1 = new FeatureDescription();
    f1.setName("one");
    f1.setDescription(null);

    Ebean.save(f1);

    ServerCache beanCache = Ebean.getServerCacheManager().getBeanCache(FeatureDescription.class);
    beanCache.getStatistics(true);

    OrmQueryDetail tunedDetail = new OrmQueryDetail();
    tunedDetail.select("name");
    TunedQueryInfo tunedInfo = new TunedQueryInfo(null, tunedDetail, 0);

    Query<FeatureDescription> query = Ebean.find(FeatureDescription.class).setId(f1.getId());

    tunedInfo.autoFetchTune((SpiQuery<?>) query);

    query.findUnique(); // PUT into cache

    FeatureDescription fd2 = query.findUnique(); // LOAD cache

    fd2.getDescription(); // invoke lazy load (this fails)

    // load the cache
    FeatureDescription fetchOne = Ebean.find(FeatureDescription.class, f1.getId());
    Assert.assertNotNull(fetchOne);
    Assert.assertEquals(1, beanCache.getStatistics(false).getSize());

    FeatureDescription fetchTwo = Ebean.find(FeatureDescription.class, f1.getId());
    FeatureDescription fetchThree = Ebean.find(FeatureDescription.class, f1.getId());
    Assert.assertSame(fetchTwo, fetchThree);

    String description = fetchThree.getDescription();
    Assert.assertNull(description);
  }
View Full Code Here

TOP

Related Classes of com.avaje.tests.model.basic.FeatureDescription

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.