Package com.j256.ormlite.dao.Dao

Examples of com.j256.ormlite.dao.Dao.CreateOrUpdateStatus


     * AndroidConnectionSource, otherwise it will go recursive if the subclass calls getConnectionSource().
     */
    DatabaseConnection conn = cs.getSpecialConnection();
    boolean clearSpecial = false;
    if (conn == null) {
      conn = new AndroidDatabaseConnection(db, true);
      try {
        cs.saveSpecialConnection(conn);
        clearSpecial = true;
      } catch (SQLException e) {
        throw new IllegalStateException("Could not save special connection", e);
View Full Code Here


     * AndroidConnectionSource, otherwise it will go recursive if the subclass calls getConnectionSource().
     */
    DatabaseConnection conn = cs.getSpecialConnection();
    boolean clearSpecial = false;
    if (conn == null) {
      conn = new AndroidDatabaseConnection(db, true);
      try {
        cs.saveSpecialConnection(conn);
        clearSpecial = true;
      } catch (SQLException e) {
        throw new IllegalStateException("Could not save special connection", e);
View Full Code Here

    foo1.equal = equal1;
    assertEquals(1, dao.create(foo1));

    int equal2 = 4134132;
    foo1.equal = equal2;
    CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
    assertFalse(status.created);
    assertTrue(status.updated);
    assertEquals(1, status.numLinesChanged);

    Foo fooResult = dao.queryForId(foo1.id);
View Full Code Here

    results = dao.queryForAll();
    assertNotNull(results);
    assertEquals(1, results.size());
    assertEquals(val2, results.get(0).val);

    CreateOrUpdateStatus status = dao.createOrUpdate(foo);
    assertNotNull(status);
    assertTrue(status.isUpdated());

    int id2 = foo.id + 1;
    assertEquals(1, dao.updateId(foo, id2));
    assertNull(dao.queryForId(id1));
    assertNotNull(dao.queryForId(id2));
View Full Code Here

  public void testCreateOrUpdate() throws Exception {
    Dao<Foo, Integer> dao = createDao(Foo.class, true);
    Foo foo1 = new Foo();
    int equal1 = 21313;
    foo1.equal = equal1;
    CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
    assertTrue(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    int equal2 = 4134132;
    foo1.equal = equal2;
    status = dao.createOrUpdate(foo1);
    assertFalse(status.isCreated());
    assertTrue(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    Foo fooResult = dao.queryForId(foo1.id);
    assertEquals(equal2, fooResult.equal);
  }
View Full Code Here

  }

  @Test
  public void testCreateOrUpdateNull() throws Exception {
    Dao<Foo, Integer> dao = createDao(Foo.class, true);
    CreateOrUpdateStatus status = dao.createOrUpdate(null);
    assertFalse(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(0, status.getNumLinesChanged());
  }
View Full Code Here

  public void testCreateOrUpdateNullId() throws Exception {
    Dao<CreateOrUpdateObjectId, Integer> dao = createDao(CreateOrUpdateObjectId.class, true);
    CreateOrUpdateObjectId foo = new CreateOrUpdateObjectId();
    String stuff = "21313";
    foo.stuff = stuff;
    CreateOrUpdateStatus status = dao.createOrUpdate(foo);
    assertTrue(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    CreateOrUpdateObjectId result = dao.queryForId(foo.id);
    assertNotNull(result);
    assertEquals(stuff, result.stuff);
View Full Code Here

  @Test
  public void testCreateOrUpdate() throws Exception {
    Dao<NotQuiteFoo, Integer> dao = createDao(NotQuiteFoo.class, true);
    NotQuiteFoo foo1 = new NotQuiteFoo();
    foo1.stuff = "wow";
    CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
    assertTrue(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    String stuff2 = "4134132";
    foo1.stuff = stuff2;
    status = dao.createOrUpdate(foo1);
    assertFalse(status.isCreated());
    assertTrue(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    NotQuiteFoo result = dao.queryForId(foo1.id);
    assertEquals(stuff2, result.stuff);
  }
View Full Code Here

  }

  @Test
  public void testCreateOrUpdateNull() throws Exception {
    Dao<Foo, String> dao = createDao(Foo.class, true);
    CreateOrUpdateStatus status = dao.createOrUpdate(null);
    assertFalse(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(0, status.getNumLinesChanged());
  }
View Full Code Here

  public void testCreateOrUpdateNullId() throws Exception {
    Dao<CreateOrUpdateObjectId, Integer> dao = createDao(CreateOrUpdateObjectId.class, true);
    CreateOrUpdateObjectId foo = new CreateOrUpdateObjectId();
    String stuff = "21313";
    foo.stuff = stuff;
    CreateOrUpdateStatus status = dao.createOrUpdate(foo);
    assertTrue(status.isCreated());
    assertFalse(status.isUpdated());
    assertEquals(1, status.getNumLinesChanged());

    CreateOrUpdateObjectId result = dao.queryForId(foo.id);
    assertNotNull(result);
    assertEquals(stuff, result.stuff);
View Full Code Here

TOP

Related Classes of com.j256.ormlite.dao.Dao.CreateOrUpdateStatus

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.