Package com.avaje.ebean

Examples of com.avaje.ebean.EbeanServer


    checkForLoop();
  }
 
  private void checkForLoop() {
   
    EbeanServer server = Ebean.getServer(null);
   
    Query<TOne> query = server.find(TOne.class)
      .where().gt("name", "2")
      .query();
 
    int pageSize = 10;
   
    PagingList<TOne> pagingList = server.findPagingList(query, null, pageSize);

    List<TOne> asList = pagingList.getAsList();
    for (int i = 0; i < asList.size(); i++) {
      if (i % 10 == 0){
        //System.out.println("here");
View Full Code Here


    config.setDdlRun(true);
    config.setAutoCommitMode(true);
    GlobalProperties.setSkipPrimaryServer(true);
   
    EbeanServer ebeanServer = EbeanServerFactory.create(config);
   
   
    UTDetail detail1 = new UTDetail("one", 12, 30D);
    UTDetail detail2 = new UTDetail("two", 11, 30D);
    UTDetail detail3 = new UTDetail("three", 8, 30D);
   
    Transaction txn = ebeanServer.beginTransaction();
    try {
      txn.setBatchMode(true);
      ebeanServer.save(detail1);
      ebeanServer.save(detail2);
      ebeanServer.save(detail3);
      txn.commit();
     
    } finally {
      txn.end();
    }
   
    List<UTDetail> details = ebeanServer.find(UTDetail.class).findList();
    Assert.assertEquals(3, details.size());
   
  }
View Full Code Here


  @Test
  public void test() {

    EbeanServer server = Ebean.getServer(null);
    Assert.assertNotNull(server);
   
    SpiEbeanServer spiServer = (SpiEbeanServer)server;
    BeanDescriptor<IMRoot> beanDescriptor = spiServer.getBeanDescriptor(IMRoot.class);
    InheritInfo inheritInfo = beanDescriptor.getInheritInfo();
    Assert.assertNotNull(inheritInfo);

   
    IMRootOne one = new IMRootOne();
    one.setName("One Name");
    server.save(one);
    add(one, "aaa");
    add(one, "bbb");
   

   
    IMRootTwo two = new IMRootTwo();
    two.setTitle("Two Title");
    server.save(two);
    add(two, "ccc");
    add(two, "ddd");
       
   
    List<IMRoot> list = server.find(IMRoot.class).select("id").findList();
   
    for (IMRoot imRoot : list) {
      // lazy load the related OneToMany which is related to a non-leaf
      List<IMRelated> related = imRoot.getRelated();
      for (IMRelated imRelated : related) {
View Full Code Here

   
    IMRelated relate = new IMRelated();
    relate.setName(string);
    relate.setOwner(owner);
   
    EbeanServer server = Ebean.getServer(null);
    server.save(relate);
  }
View Full Code Here

    List<Customer> list = Ebean.find(Customer.class).select("id, name, status, shippingAddress")
        .fetch("billingAddress", "line1, city").fetch("billingAddress.country", "*")
        .fetch("contacts", "firstName,email")
        .order().desc("id").findList();

    EbeanServer server = Ebean.getServer(null);

    JsonContext json = server.json();

    String jsonOutput = json.toJson(list);
    System.out.println(jsonOutput);

    List<Customer> mList = json.toList(Customer.class, jsonOutput);
View Full Code Here

    ResetBasicData.reset();

    List<Customer> list = Ebean.find(Customer.class).select("id, name").order().desc("id")
        .findList();

    EbeanServer server = Ebean.getServer(null);

    JsonContext json = server.json();

    if (list.size() > 1) {
      Customer customer = list.get(0);

      String s = json.toJson(customer);
View Full Code Here

  @Test
  public void testFutureRowCount() throws InterruptedException {
   
    ResetBasicData.reset();
   
    EbeanServer server = Ebean.getServer(null);
   
    Query<Customer> query = server.createQuery(Customer.class)
      .where().eq("doesNotExist", "this will fail")
      .query();
     
    FutureRowCount<Customer> futureRowCount = server.findFutureRowCount(query, null);
   
    QueryFutureRowCount<Customer> internalRowCount = (QueryFutureRowCount<Customer>)futureRowCount;
    Transaction t = internalRowCount.getTransaction();
   
    try {
View Full Code Here

  @Test
  public void testFutureIds() throws InterruptedException {
   
    ResetBasicData.reset();
   
    EbeanServer server = Ebean.getServer(null);
   
    Query<Customer> query = server.createQuery(Customer.class)
      .where().eq("doesNotExist", "this will fail")
      .query();
     
    FutureIds<Customer> futureIds = server.findFutureIds(query, null);
   
    QueryFutureIds<Customer> internalFuture = (QueryFutureIds<Customer>)futureIds;
    Transaction t = internalFuture.getTransaction();
   
    try {
View Full Code Here

  @Test
  public void testFutureList() throws InterruptedException {
   
    ResetBasicData.reset();
   
    EbeanServer server = Ebean.getServer(null);
   
    Query<Customer> query = server.createQuery(Customer.class)
      .where().eq("doesNotExist", "this will fail")
      .query();
     
    FutureList<Customer> futureList = server.findFutureList(query, null);
   
    QueryFutureList<Customer> internalFuture = (QueryFutureList<Customer>)futureList;
    Transaction t = internalFuture.getTransaction();
   
    try {
View Full Code Here

   
    private List<Object> findIdsByParentId(Object parentId, Transaction t) {
       
        String rawWhere = deriveWhereParentIdSql(false);
       
        EbeanServer server = getBeanDescriptor().getEbeanServer();
        Query<?> q = server.find(getPropertyType())
            .where().raw(rawWhere).query();
       
        bindWhereParendId(q, parentId);
        return server.findIds(q, t);
    }
View Full Code Here

TOP

Related Classes of com.avaje.ebean.EbeanServer

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.