This is a cache of http://dbflute.seasar.org/ja/manual/function/ormapper/conditionbean/various/todisplaysql.html. It is a snapshot of the page at 2024-03-19T00:30:08.382+0000.
CB - ToDi<strong>s</strong>play<strong>s</strong>ql | <strong>dbflute</strong>

CB - ToDisplaysql

概要

基本概念

ConditionBeanの条件をもとにした 表示用sQL を取得することができます。

ConditionBeanから外だしsQLに移行するに、外だしsQLの土台sQLとして利用できます。

実装方法

実装の流れ

まずは通常通り、ConditionBeanの実装をしてから、toDisplaysql() を呼び出します。戻り値の文字列をログなどに出力して、外だしsQLの土台sQLとして活用します。

e.g. toDisplaysql()の実装手順 (Eclipseでコード補完) @Java
MemberCB() cb = new MemberCB();
cb.setupselect_Memberstatus();
cb.query().setMemberName_Prefixsearch("s");
cb.query().addOrderBy_Birthdate_Desc();
cb.toDs // .toDs と打って enter
--
cb.toDisplaysql(); // セミコロン付けて、ctrl + 2 そして L
--
string sql = cb.toDisplaysql();
_log.debug(sql);

メソッド仕様

サブクエリ用の ConditionBean (ExistsReferrer などの subQuery コールバック内のCB)などにおいては、select 句などは厳密にはサブクエリとしてのsQLとは一致しません。