rubbish-db / チュートリアル / DAOを自動生成する / SELECT


[ 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("----------");

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

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

Book[] books01 = bookDAO.selectByPublisher("04");

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

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

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

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

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

Book[] books03 = bookDAO.selectByPublisherAuthorIssue_date("05", "竹乃元秀路", null);

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

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

dbh.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
----------
'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}
----------
'SELECT * FROM BOOK WHERE PUBLISHER = ? [04]'
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=000, issue_date=null, publisher=04, title=あなたにも出来る!中国拳法修行百科, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=04, title=エーゲ海-古代格闘史の浪漫-, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=002, issue_date=null, publisher=04, title=ギリシャ神話に見る現代人への教訓, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=003, issue_date=null, publisher=04, title=シルクロードの彼方, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=004, issue_date=null, publisher=04, title=暗黒組織類聚, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=005, issue_date=null, publisher=04, title=英国貴族の習慣・風俗, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=006, issue_date=null, publisher=04, title=眼球大脳生理学, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=007, issue_date=null, publisher=04, title=世界幻覚大全, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=008, issue_date=null, publisher=04, title=世界残虐刑罰史, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=009, issue_date=null, publisher=04, title=世界頭髪大全, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=010, issue_date=null, publisher=04, title=中国拳法-火の考察-, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=011, issue_date=null, publisher=04, title=動物棲息類聚, update_date=2005-06-10 17:10:00.000}
----------
'SELECT * FROM BOOK WHERE ID = ? [001]'
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=01, title=騎馬民族の逆襲, update_date=2005-06-10 17:10:00.000}
Book@{author=中津川大観, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=02, title=戦場にかける橋, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=03, title=世界名物兄弟-この兄あってこの弟あり-, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=04, title=エーゲ海-古代格闘史の浪漫-, update_date=2005-06-10 17:10:00.000}
Book@{author=盛田慎之介, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=05, title=天釐蜘巣, update_date=2005-06-10 17:10:00.000}
Book@{author=null, create_date=1999-06-10 17:10:00.000, id=001, issue_date=null, publisher=06, title=SKATER'SWALTZ, update_date=2005-06-10 17:10:00.000}
----------
'SELECT * FROM BOOK WHERE PUBLISHER = ? AND AUTHOR = ? AND ISSUE_DATE IS NULL [05, 竹乃元秀路]'
Book@{author=竹乃元秀路, 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}
----------
disconnect database.