Search in sources :

Example 1 with Issue1Pojo

use of org.sql2o.issues.pojos.Issue1Pojo in project sql2o by aaberg.

the class IssuesTest method testSetterPriority.

/**
 * Tests for issue #1 https://github.com/aaberg/sql2o/issues/1
 *
 * Issue:
 * I have a case where I need to override/modify the value loaded from db.
 * I want to do this in a setter but the current version of sql2o modifies the property directly.
 *
 * Comment:
 * The priority was wrong. Sql2o would try to set the field first, and afterwards the setter. The priority should be
 * the setter first and the field after.
 */
@Test
public void testSetterPriority() {
    Sql2o sql2o = new Sql2o(url, user, pass);
    Issue1Pojo pojo = sql2o.createQuery("select 1 val from (values(0))").executeAndFetchFirst(Issue1Pojo.class);
    assertEquals(2, pojo.val);
}
Also used : Sql2o(org.sql2o.Sql2o) Issue1Pojo(org.sql2o.issues.pojos.Issue1Pojo) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Sql2o (org.sql2o.Sql2o)1 Issue1Pojo (org.sql2o.issues.pojos.Issue1Pojo)1