[ rubbish-db ]

ソース

Map row = Publisher.join(Book.class).find(Publisher.ID.eq("01").and(Book.ID.eq("001")));
println(row.get(Publisher.class));
println(row.get(Book.class));

Map[] rows01 = Book.join(Publisher.class).findAny(Publisher.ID.eq("02"));

for (int i = 0; i < rows01.length; i++) {
    Publisher publisher = (Publisher) rows01[i].get(Publisher.class);
    Book book = (Book) rows01[i].get(Book.class);
    println(publisher.getName() + ": " + book.getTitle());
}

Map[] rows02 = Publisher.join("PU", Book.class, "BO").findAny("PU.ID = BO.PUBLISHER AND PU.ID = ?", "01");

for (int i = 0; i < rows02.length; i++) {
    Publisher publisher = (Publisher) rows02[i].get(Publisher.class);
    Book book = (Book) rows02[i].get(Book.class);
    println(publisher.getName() + ": " + book.getTitle());
}

DatabaseManager.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
'SELECT PUBLISHER.CREATE_DATE, PUBLISHER.ID, PUBLISHER.NAME, PUBLISHER.UPDATE_DATE, PUBLISHER.VOLUMES, BOOK.AUTHOR, BOOK.CREATE_DATE, BOOK.ID, BOOK.ISSUE_DATE, BOOK.PUBLISHER, BOOK.TITLE, BOOK.UPDATE_DATE FROM PUBLISHER, BOOK WHERE PUBLISHER.ID = BOOK.PUBLISHER AND PUBLISHER.ID = ? AND BOOK.ID = ? [01, 001]'
Publisher@{create_date=1999-07-10 17:10:00.000, id=01, name=栄学館, update_date=2005-07-10 17:10:00.000, volumes=4}
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}
 'SELECT BOOK.AUTHOR, BOOK.CREATE_DATE, BOOK.ID, BOOK.ISSUE_DATE, BOOK.PUBLISHER, BOOK.TITLE, BOOK.UPDATE_DATE, PUBLISHER.CREATE_DATE, PUBLISHER.ID, PUBLISHER.NAME, PUBLISHER.UPDATE_DATE, PUBLISHER.VOLUMES FROM BOOK, PUBLISHER WHERE PUBLISHER.ID = BOOK.PUBLISHER AND PUBLISHER.ID = ? [02]'
時源出版: 偉大なる中国拳法
時源出版: 戦場にかける橋
時源出版: 中国拳法裏面史
時源出版: 武芸秘史
'SELECT BO.AUTHOR, BO.CREATE_DATE, BO.ID, BO.ISSUE_DATE, BO.PUBLISHER, BO.TITLE, BO.UPDATE_DATE, PU.CREATE_DATE, PU.ID, PU.NAME, PU.UPDATE_DATE, PU.VOLUMES FROM BOOK BO, PUBLISHER PU WHERE PU.ID = BO.PUBLISHER AND PU.ID = ? [01]'
栄学館: インド母なる大地を往く
栄学館: 騎馬民族の逆襲
栄学館: 中国武闘三千年
栄学館: 武家社会に於ける風俗・迷信
disconnect database.