Examples of EbeanServer


Examples of com.avaje.ebean.EbeanServer

  /**
   * Create a ScopeTrans for a given methods TxScope.
   */
  public static ScopeTrans createScopeTrans(TxScope txScope) {
   
    EbeanServer server = Ebean.getServer(txScope.getServerName());
    SpiEbeanServer iserver = (SpiEbeanServer)server;
    return iserver.createScopeTrans(txScope);
  }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

public class TestSeqBatch extends BaseTestCase {

  @Test
  public void test() {
   
    EbeanServer server = Ebean.getServer(null);
    SpiEbeanServer spiServer = (SpiEbeanServer)server;
   
    boolean seqSupport = spiServer.getDatabasePlatform().getDbIdentity().isSupportsSequence();
   
    if (seqSupport){
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

  @Test
  public void test() {
   
    ResetBasicData.reset();
   
    EbeanServer server = Ebean.getServer(null);
    Product prod1 = createProduct(100,"apples");
    server.insert(prod1);
    Product prod2 = createProduct(101, "bananas");
    server.insert(prod2);
   
    server.beginTransaction();
    // effectively load these into the persistence context
    server.find(Product.class, prod1.getId());
    server.find(Product.class, prod2.getId());
   
    server.delete(Product.class, Arrays.asList(prod1.getId(), prod2.getId()));
   
    // are these found in the persistence context?
    Product shadow1 = server.find(Product.class, prod1.getId());
    Product shadow2 = server.find(Product.class, prod2.getId());
   
    Assert.assertNull(shadow1);
    Assert.assertNull(shadow2);
   
    server.endTransaction();
   
  }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

  // public void testRunManually() {
  public void notRanAutomatically() {

    GlobalProperties.put("datasource.default", "");
    EbeanServer server = CreateIdExpandedFormServer.create();

    ROrderPK k0 = new ROrderPK("compa", 100);
    ROrderPK k1 = new ROrderPK("compa", 101);
    ROrderPK k2 = new ROrderPK("b", 105);
    ROrderPK k3 = new ROrderPK("c", 106);

    List<ROrderPK> keys = new ArrayList<ROrderPK>();
    keys.add(k0);
    keys.add(k1);
    keys.add(k2);
    keys.add(k3);

    Query<ROrder> query = server.find(ROrder.class).where().idIn(keys).query();

    query.findList();
    String sql = query.getGeneratedSql();

    Assert.assertTrue(sql.contains("(r.company=? and r.order_number=?) or"));

    Query<ROrder> query2 = server.find(ROrder.class).setId(k0);

    query2.findUnique();
    sql = query2.getGeneratedSql();
    Assert.assertTrue(sql.contains("r.company = ? "));
    Assert.assertTrue(sql.contains(" and r.order_number = ?"));

    server.delete(ROrder.class, k0);

    server.delete(ROrder.class, keys);

  }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

public class TestResourceFileSelfRef {

  @Test
  public void test() {
   
    EbeanServer server = Ebean.getServer(null);

    ResourceFile childFile1 = new ResourceFile();
    childFile1.setName("childFile1");
    ResourceFile childFile2 = new ResourceFile();
    childFile2.setName("childFile2");

    ResourceFile parentFile1 = new ResourceFile();
    parentFile1.setName("parentFile1");

    childFile1.setParent(parentFile1);
    childFile2.setParent(parentFile1);
    parentFile1.getAlternatives().add(childFile1);
    parentFile1.getAlternatives().add(childFile2);

    server.save(parentFile1);
    server.save(childFile1);
    server.save(childFile2);

    // As a workaround for the problem, the child objects can be deleted first
    //server.delete(childFile1);
    //server.delete(childFile2);
    server.delete(parentFile1);
  }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

public class TestQueryCacheInsert extends BaseTestCase {

  @Test
  public void test() {

    EbeanServer server = Ebean.getServer(null);

    EBasicVer account = new EBasicVer();
    server.save(account);

    List<EBasicVer> alist0 = server.find(EBasicVer.class).setUseQueryCache(true).findList();

    EBasicVer a2 = new EBasicVer();
    server.save(a2);

    List<EBasicVer> alist1 = server.find(EBasicVer.class).setUseQueryCache(true).findList();

    Assert.assertEquals(alist0.size() + 1, alist1.size());
    // List<EBasicVer> noQueryCacheList = server.find(EBasicVer.class)
    // .setUseQueryCache(false)
    // .findList();
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

public class TestPersistenceContextOnUpdateDuringTxn extends BaseTestCase {

  @Test
  public void test() {
   
    EbeanServer server = Ebean.getServer(null);
   
    server.beginTransaction();
    try {
     
      EBasic bean1 = new EBasic();
      bean1.setName("hello");
     
      server.save(bean1);
     
      EBasic updatedEntity = new EBasic();
      updatedEntity.setId(bean1.getId());
      updatedEntity.setName("hello-changed");
     
      server.update(updatedEntity);
     
      // actually the bean is not in the persistence context so ...  the assert is fine
      EBasic loadedEntity = server.find(EBasic.class,bean1.getId());

      assertThat(loadedEntity.getName(), is("hello-changed"));

    } finally {
      server.endTransaction();
    }
   
  }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

        //UnderscoreNamingConvention naming = new UnderscoreNamingConvention();
        //naming.setSchema("test");
        //cfg.setNamingConvention(naming);
        cfg.setDdlGenerate(true);
        cfg.setDdlRun(true);
        EbeanServer ebean = EbeanServerFactory.create(cfg);
        //ebean.createSqlUpdate("create schema foo").execute();
        System.out.println(ebean);
    }
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

    Assert.assertEquals(0, pc.size(Customer.class));

    Order order0 = null;
    try {

      EbeanServer server = Ebean.getServer(null);
      List<Order> list = server.find(Order.class).fetch("customer").fetch("details").findList();

      int orderSize = list.size();
      Assert.assertTrue(orderSize > 1);

      // keep a hold of one of them
View Full Code Here

Examples of com.avaje.ebean.EbeanServer

public class TestProtectedConstructor extends BaseTestCase {

  @Test
  public void test() {
   
    EbeanServer server = Ebean.getServer(null);
   
    // check that we can construc a bean with a protected constructor
    MProtectedConstructBean bean = server.createEntityBean(MProtectedConstructBean.class);
    Assert.assertNotNull(bean);

    // Note1 that the enhancement ClassAdapterEntity line 239 makes a default constructor publically accessible
    // Note2 the ClassAdpater will call DefaultConstructor.add() to add a default constructor if it doesn't exist
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.