[ 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.updateByPK("06", "002", new FSET() {
    public String title = "○△□";

    public Date issue_date = null;
});

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

dbh.rollback();

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

Integer rows02 = bookDAO.updateByPublisher("04", new FSET() {
    public String title = "×××××";

    public Date create_date = new ZDate("2006-10-10");
});

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

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

dbh.rollback();

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

bookDAO.updateById("001", new FSET() {
    public String author = "山田太郎";

    public Date update_date = new ZDate("2006-10-10");
});

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

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

dbh.rollback();

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

int rows03 = bookDAO.updateByPublisherAuthorIssue_date("05", "竹乃元秀路", null, new FSET() {
    public String title = "題目";

    public String author = null;
});

println("rows=" + rows03);
Book[] books03 = bookDAO.selectByPublisherAuthorIssue_date("05", null, 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='.
----------
'UPDATE BOOK SET ISSUE_DATE = ?, TITLE = ? WHERE PUBLISHER = ? AND ID = ? [null, ○△□, 06, 002]'
rows=1
'SELECT * FROM BOOK WHERE PUBLISHER = ? AND ID = ? [06, 002]'
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=002, issue_date=null, publisher=06, title=○△□, update_date=2005-06-10 17:10:00.000}
rollback transaction.
----------
'UPDATE BOOK SET TITLE = ?, CREATE_DATE = ? WHERE PUBLISHER = ? [×××××, 2006-10-10 00:00:00.000, 04]'
rows=12
'SELECT * FROM BOOK WHERE PUBLISHER = ? [04]'
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=000, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=001, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=002, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=003, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=004, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=005, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=006, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=007, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=008, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=009, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=010, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=2006-10-10 00:00:00.000, id=011, issue_date=null, publisher=04, title=×××××, update_date=2005-06-10 17:10:00.000}
rollback transaction.
----------
'UPDATE BOOK SET UPDATE_DATE = ?, AUTHOR = ? WHERE ID = ? [2006-10-10 00:00:00.000, 山田太郎, 001]'
'SELECT * FROM BOOK WHERE ID = ? [001]'
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=01, title=騎馬民族の逆襲, update_date=2006-10-10 00:00:00.000}
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=02, title=戦場にかける橋, update_date=2006-10-10 00:00:00.000}
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=03, title=世界名物兄弟-この兄あってこの弟あり-, update_date=2006-10-10 00:00:00.000}
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=04, title=エーゲ海-古代格闘史の浪漫-, update_date=2006-10-10 00:00:00.000}
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=05, title=天釐蜘巣, update_date=2006-10-10 00:00:00.000}
Book@{author=山田太郎, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=06, title=SKATER'SWALTZ, update_date=2006-10-10 00:00:00.000}
rollback transaction.
----------
'UPDATE BOOK SET TITLE = ?, AUTHOR = ? WHERE PUBLISHER = ? AND AUTHOR = ? AND ISSUE_DATE IS NULL [題目, null, 05, 竹乃元秀路]'
rows=1
'SELECT * FROM BOOK WHERE PUBLISHER = ? AND AUTHOR IS NULL AND ISSUE_DATE IS NULL [05]'
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=000, issue_date=null, publisher=05, title=題目, update_date=2005-06-10 17:10:00.000}
rollback transaction.
----------
disconnect database.