Examples of EBasic


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

    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.tests.model.basic.EBasic

  public static void main(String[] args) {
     
    EbeanServer defaultServer = Ebean.getServer(null);
   
    EBasic e = new EBasic();
    e.setName("blah");
    e.setStatus(Status.NEW);
    e.setDescription(null);
   
    defaultServer.save(e);
   
    EBasic e1 = defaultServer.find(EBasic.class, e.getId());
   
    EbeanServer serverDest = Ebean.getServer("mysql");
   
    serverDest.insert(e1);
   
View Full Code Here

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

      Date daylightSavingDate = new Date(1351382400000l);
      // On a second run comment in the following date and see
      // how there is a 0 second change
      // daylightSavingDate = new Date(1361382400000l);

      EBasic e = new EBasic();
      e.setSomeDate(daylightSavingDate);

      Ebean.save(e);
      Assert.assertNotNull(e.getId());

      // Reload the entity from database
      EBasic e2 = Ebean.find(EBasic.class, e.getId());

      long diffMillis = e2.getSomeDate().getTime() - e.getSomeDate().getTime();

      System.out.println("The date I created " + daylightSavingDate);
      System.out.println(" --- the date i put in   : " + e.getSomeDate());
      System.out.println("          as millis      : " + e.getSomeDate().getTime());
      System.out.println(" --- the date i get back : " + e2.getSomeDate());
      System.out.println("          as millis      : " + e2.getSomeDate().getTime());
      System.out.println("The difference is " + diffMillis / 1000 + " seconds");

      Assert.assertEquals(0L, diffMillis);
     
    } finally {
View Full Code Here

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

    Transaction transaction = server.beginTransaction();
    try {
      transaction.setBatchMode(true);
      transaction.setBatchSize(20);
      for (int i = 0; i < 10000; i++) {
        EBasic dumbModel = new EBasic();
        dumbModel.setName("Hello");
        server.save(dumbModel);
      }
      transaction.commit();

    } finally {
View Full Code Here

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

public class TestUpdatePartialNoVer extends BaseTestCase {

  @Test
  public void test() {

    EBasic b = new EBasic();
    b.setName("testpart");
    b.setStatus(Status.ACTIVE);
    b.setDescription("description");

    Ebean.save(b);

    EBasic basic = Ebean.find(EBasic.class).select("status, name").setId(b.getId()).findUnique();

    basic.setName("modiName");

    Ebean.save(basic);

  }
View Full Code Here

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

    Transaction transaction = server.beginTransaction();
    try {
      transaction.setBatchMode(true);
      transaction.setBatchSize(20);
      for (int i = 0; i < 87; i++) {
        EBasic dumbModel = new EBasic();
        dumbModel.setName("HelloB0Bi");
        server.save(dumbModel);
      }
      transaction.commit();

    } finally {
View Full Code Here

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

public class TestWhereLikeWithSlash  extends BaseTestCase {

  @Test
  public void test() {
 
    EBasic basic = new EBasic();
    basic.setName("slash\\monkey");
   
    Ebean.save(basic);
   
   
    Query<EBasic> query = Ebean.find(EBasic.class).where().like("name", "slash\\mon%").query();
View Full Code Here

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

public class TestExplicitInsert extends BaseTestCase {

  @Test
  public void test() {

    EBasic b = new EBasic();
    b.setName("exp insert");
    b.setDescription("explicit insert");
    b.setStatus(EBasic.Status.ACTIVE);

    EbeanServer server = Ebean.getServer(null);
    server.insert(b);

    Assert.assertNotNull(b.getId());

    EBasic b2 = server.find(EBasic.class, b.getId());
    b2.setId(null);

    b2.setName("force insert");
    server.insert(b2);

    Assert.assertNotNull(b2.getId());
    Assert.assertTrue(!b.getId().equals(b2.getId()));

    List<EBasic> list = server.find(EBasic.class).where().in("id",b.getId(), b2.getId()).findList();

    Assert.assertEquals(2, list.size());
  }
View Full Code Here

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

  public void test() {

    // GlobalProperties.put("ebean.defaultUpdateNullProperties", "true");
    // GlobalProperties.put("ebean.defaultDeleteMissingChildren", "false");

    EBasic e = new EBasic();
    e.setName("something");
    e.setStatus(Status.NEW);
    e.setDescription("wow");

    server.save(e);

    EBasic updateAll = new EBasic();
    updateAll.setId(e.getId());
    updateAll.setName("updAllProps");

    server.update(updateAll, null, false);

    EBasic updateDeflt = new EBasic();
    updateDeflt.setId(e.getId());
    updateDeflt.setName("updateDeflt");

    server.update(updateDeflt);

  }
View Full Code Here

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

   * Currently a {@link javax.persistence.PersistenceException} with message 'Invalid value "null" for parameter "SQL"' is thrown.
   */
  @Test
  public void testWithoutChangesAndIgnoreNullValues() {
    // arrange
    EBasic basic = new EBasic();
    basic.setName("something");
    basic.setStatus(Status.NEW);
    basic.setDescription("wow");

    server.save(basic);

    // act
    EBasic basicWithoutChanges = new EBasic();
    basicWithoutChanges.setId(basic.getId());
    server.update(basicWithoutChanges);

    // assert
    // Nothing to check, simply no exception should occur
    // maybe ensure that no update has been executed
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.