Created
October 1, 2018 11:29
-
-
Save xcesco/53f654e76d1a8f3bb5b3591a41e68b4e to your computer and use it in GitHub Desktop.
Kripton ORM: select in example
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
// DAO definition | |
@BindDao(City.class) | |
public interface DaoCity { | |
@BindSqlInsert | |
long insert(City bean); | |
@BindSqlSelect(where="id in (:{dummy})") | |
List<City> selectAll2(@BindSqlParam("dummy") List<Long> args); | |
} |
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
@Test | |
public void testRuntime() { | |
BindAppDataSource.getInstance().execute((BindAppDaoFactory daoFactory) -> { | |
DaoCityImpl dao = daoFactory.getDaoCity(); | |
long id1; | |
long id2; | |
City bean1 = new City(); | |
bean1.name = "city1"; | |
id1 = dao.insert(bean1); | |
City bean2 = new City(); | |
bean2.name = "city2"; | |
id2 = dao.insert(bean2); | |
ArrayList<Long> params = new ArrayList<Long>(); | |
params.add(id1); | |
params.add(id2); | |
assertTrue(dao.selectAll2(params).size() == 2); | |
return TransactionResult.COMMIT; | |
}); | |
} |
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
I/AbstractDataSource$3, onCreate (line 450): Create database 'app.db' version 1 | |
I/AbstractDataSource$3, onCreate (line 450): DDL: CREATE TABLE city (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT); | |
I/BindAppDataSource, getInstance (line 243): database OPEN READ_AND_WRITE_OPENED (connections: 0) | |
I/BindAppDataSource, getInstance (line 244): database CLOSED (READ_AND_WRITE_OPENED) (connections: 0) | |
I/BindAppDataSource, execute (line 96): database OPEN READ_AND_WRITE_OPENED (connections: 0) | |
I/TestFeatureRuntime1, lambda$0 (line 46): INSERT INTO city (name) VALUES (:name) | |
I/TestFeatureRuntime1, lambda$0 (line 46): ==> :name = 'city1' (java.lang.String) | |
I/TestFeatureRuntime1, lambda$0 (line 50): INSERT INTO city (name) VALUES (:name) | |
I/TestFeatureRuntime1, lambda$0 (line 50): ==> :name = 'city2' (java.lang.String) | |
I/TestFeatureRuntime1, lambda$0 (line 56): SELECT id, name FROM city WHERE id in (?, ?) | |
I/TestFeatureRuntime1, lambda$0 (line 56): ==> param0: '1' | |
I/TestFeatureRuntime1, lambda$0 (line 56): ==> param1: '2' | |
I/CursorWindowStats: Created a new Cursor. # Open Cursors=1 (# cursors opened by this proc=1) | |
D/SQLiteCursor: received count(*) from native_fill_window: 2 | |
I/TestFeatureRuntime1, lambda$0 (line 56): Rows found: 2 | |
I/BindAppDataSource, execute (line 115): database CLOSED (READ_AND_WRITE_OPENED) (connections: 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment