[ rubbish-db ]

DAO

ソース

RubbishDatabase dbh = new RubbishDatabase();
dbh.setLogging(true);

dbh.connect("jdbc:hsqldb:hsql://localhost", "sa", "");
DAOFactory factory = new DAOFactory(dbh, "C:/eclipse/workspace/rubbish-db/sample/src/sample/hsqldb/dao");

BookDAO bookDAO = (BookDAO) factory._new(BookDAO.class);

println("----------");

int rows01 = bookDAO.deleteByPK("06", "002");
println("rows=" + rows01);
Book book = bookDAO.selectByPK("06", "002");
println(book);

dbh.rollback();

println("----------");

Integer rows02 = bookDAO.deleteByPublisher("04");
println("rows=" + rows02);
Book[] books01 = bookDAO.selectByPublisher("04");

for (int i = 0; i < books01.length; i++)
    println(books01[i]);

dbh.rollback();

println("----------");

bookDAO.deleteById("001");
List books02 = bookDAO.selectById("001");

for (int i = 0; i < books02.size(); i++)
    println(books02.get(i));

dbh.rollback();

println("----------");

int rows03 = bookDAO.deleteByPublisherAuthorIssue_date("05", "竹乃元秀路", null);
println("rows=" + rows03);
Book[] books03 = bookDAO.selectByPublisherAuthorIssue_date("05", "竹乃元秀路", null);

for (int i = 0; i < books03.length; i++)
    println(books03[i]);

dbh.rollback();

println("----------");

dbh.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
----------
'DELETE FROM BOOK WHERE PUBLISHER = ? AND ID = ? [06, 002]'
rows=1
'SELECT * FROM BOOK WHERE PUBLISHER = ? AND ID = ? [06, 002]'
null
rollback transaction.
----------
'DELETE FROM BOOK WHERE PUBLISHER = ? [04]'
rows=12
'SELECT * FROM BOOK WHERE PUBLISHER = ? [04]'
rollback transaction.
----------
'DELETE FROM BOOK WHERE ID = ? [001]'
'SELECT * FROM BOOK WHERE ID = ? [001]'
rollback transaction.
----------
'DELETE FROM BOOK WHERE PUBLISHER = ? AND AUTHOR = ? AND ISSUE_DATE IS NULL [05, 竹乃元秀路]'
rows=1
'SELECT * FROM BOOK WHERE PUBLISHER = ? AND AUTHOR = ? AND ISSUE_DATE IS NULL [05, 竹乃元秀路]'
rollback transaction.
----------
disconnect database.