DasClient { public <T> T queryObject(SqlBuilder builder) throws SQLException { final Hints hint = checkHints(builder.hints()); return internalExecute(hint, ()->{return delegate.queryObject(builder);}); } DasClient(DasDelegate delegate); T queryByPk(T pk, Hints...hints); List<T> queryBySample(T sample, Hints...hints); List<T> queryBySample(T sample, PageRange range, Hints...hints); long countBySample(T sample, Hints...hints); int insert(T entity, Hints...hints); int insert(List<T> entities, Hints...hints); int[] batchInsert(List<T> entities, Hints...hints); int deleteByPk(T pk, Hints...hints); int deleteBySample(T sample, Hints...hints); int[] batchDelete(List<T> entities, Hints...hints); int update(T entity, Hints...hints); int[] batchUpdate(List<T> entities, Hints...hints); T queryObject(SqlBuilder builder); T queryObjectNullable(SqlBuilder builder); List<T> query(SqlBuilder builder); List<?> batchQuery(BatchQueryBuilder builder); int update(SqlBuilder builder); int[] batchUpdate(BatchUpdateBuilder builder); void call(CallBuilder builder); int[] batchCall(BatchCallBuilder builder); void execute(Transaction transaction, Hints...hints); T execute(CallableTransaction<T> transaction, Hints...hints);  }
@Test public void testQueryObject() throws Exception { PersonDefinition p = Person.PERSON; for (int j = 0; j < TABLE_MODE; j++) { SqlBuilder builder = selectAllFrom(p).where(p.PeopleID.eq(j+1)).into(Person.class); Person pk = dao.queryObject(builder); assertNotNull(pk); assertEquals(j+1, pk.getPeopleID().intValue()); assertEquals("test", pk.getName()); } SqlBuilder builder = selectCount().from(p).intoObject(); Number n = dao.queryObject(builder); assertEquals(4, n.longValue()); for (int j = 0; j < TABLE_MODE; j++) { builder = selectAllFrom(p).where(p.PeopleID.eq(j+1)).into(Person.class).withLock(); Person pk = dao.queryObject(builder); assertNotNull(pk); assertEquals(j+1, pk.getPeopleID().intValue()); assertEquals("test", pk.getName()); } builder = selectCount().from(p).intoObject().withLock(); n = dao.queryObject(builder); assertEquals(4, n.longValue()); }
@Test public void testQueryCount() throws Exception { SqlBuilder builder = selectCount().from(p).intoObject(); Number n = dao.queryObject(builder); assertEquals(4, n.longValue()); }
@Test public void testQueryAll() throws Exception { SqlBuilder builder = selectAll().from(p).where(p.PeopleID.eq(1)).into(Person.class); Person p = dao.queryObject(builder); assertNotNull(p); assertEquals("test", p.getName()); }