Created
October 1, 2018 11:46
-
-
Save xcesco/93dc450dc397b6c8074d1810c7168657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindDao(Person.class) | |
public interface DaoPerson { | |
@BindSqlSelect(orderBy = "name", pageSize = 10) | |
PagedResult<Person> select(); | |
@BindSqlInsert | |
void insertOne(String pk, String name, String surname, String birthCity, Date birthDay); | |
@BindSqlSelect(orderBy = "name") | |
List<Person> selectAll(); | |
@BindSqlDelete | |
int deleteAll(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try (BindPerson1DataSource dataSource = BindPerson1DataSource.open(); Dao1PersonImpl dao = dataSource.getDao1Person()) { | |
dao.deleteAll(); | |
for (int i = 0; i < 100; i++) { | |
dao.insertOne(String.format("name%03d", i), String.format("surname%03d", i), | |
String.format("birthCity%03d", i), new Date()); | |
} | |
PagedResult<Person> result = dao.select(); | |
int i = 0; | |
result.firstPage(); | |
while (result.hasNext()) { | |
Logger.info("---------------"); | |
Logger.info("\tPage " + i); | |
Logger.info("---------------"); | |
for (Person item : result.getList()) { | |
Logger.info(item.toString()); | |
} | |
assertTrue(result.getList().get(0).name.equals(String.format("name%03d", i * 10))); | |
i++; | |
result.nextPage(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment