|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectorg.seasar.extension.jdbc.query.AbstractQuery<S>
org.seasar.extension.jdbc.query.AbstractSelect<T,AutoSelect<T>>
org.seasar.extension.jdbc.query.AutoSelectImpl<T>
T
- エンティティの型です。public class AutoSelectImpl<T>
AutoSelect
の実装クラスです。
フィールドの概要 | |
---|---|
protected Map<String,? extends Object> |
conditions
Mapによるwhere句の条件指定です。 |
protected boolean |
count
SELECT COUNT(*)~で行数を取得する場合に true |
protected String |
criteria
クライテリアです。 |
protected Object[] |
criteriaParams
クライテリア内のパラメータの配列です。 |
protected String[] |
criteriaPropertyNames
クライテリア内のパラメータに対応するプロパティ名の配列です。 |
protected Map<String,AbstractEntityMapper> |
entityMapperMap
エンティティマッパーのマップです。 |
protected Map<String,EntityMeta> |
entityMetaMap
エンティティメタデータのマップです。 |
protected String |
entityName
エンティティ名です。 |
protected String |
forUpdate
SELECT ~ FOR UPDATEのSQL文字列です。 |
protected Map<String,String> |
forUpdateTargets
SELECT ~ FOR UPDATEでロック対象となるエンティティからプロパティへのマップです。 |
protected SelectForUpdateType |
forUpdateType
SELECT ~ FOR UPDATEのタイプです。 |
protected int |
forUpdateWaitSeconds
SELECT ~ FOR UPDATEでの待機時間 (秒単位) です。 |
protected FromClause |
fromClause
from句です。 |
protected String |
hint
ヒントです。 |
protected Object[] |
idProperties
IDプロパティの値の配列です。 |
protected List<PropertyMeta> |
idPropertyMetaList
IDプロパティのメタデータのリストです。 |
protected List<JoinMeta> |
joinMetaList
結合メタデータのリストです。 |
protected String |
orderBy
ソート順です。 |
protected OrderByClause |
orderByClause
order by句です。 |
protected SelectClause |
selectClause
select句です。 |
protected int |
selectListIndex
selectリストのインデックスです。 |
protected Map<String,String> |
tableAliasMap
テーブル別名のマップです。 |
protected int |
tableIndex
テーブルのインデックスです。 |
protected List<ValueType> |
valueTypeList
値タイプのリストです。 |
protected Object |
versionProperty
バージョンプロパティの値です。 |
protected PropertyMeta |
versionPropertyMeta
バージョンプロパティのメタデータです。 |
protected WhereClause |
whereClause
where句です。 |
クラス org.seasar.extension.jdbc.query.AbstractSelect から継承されたフィールド |
---|
baseClass, disallowNoResult, fetchSize, limit, maxRows, offset, resultLob, resultTemporalType |
クラス org.seasar.extension.jdbc.query.AbstractQuery から継承されたフィールド |
---|
callerClass, callerMethodName, executedSql, jdbcManager, logger, paramList, queryTimeout |
コンストラクタの概要 | |
---|---|
AutoSelectImpl(JdbcManagerImplementor jdbcManager,
Class<T> baseClass)
AutoSelectImpl を作成します。 |
メソッドの概要 | |
---|---|
protected String |
convertCriteria(String str)
プロパティ名で記述されたクライテリアをカラム名に変換します。 |
protected String |
convertEntityNameToTableAlias(String str)
文字列中のエンティティ名をテーブルの別名に変換します。 |
protected ResultSetHandler |
createIterateResultSetHandler(IterationCallback<T,?> callback)
反復する結果セットハンドラを作成します。 |
protected AbstractRelationshipEntityMapper |
createRelationshipEntityMapper(Class<?> relationshipClass,
PropertyMapper[] propertyMappers,
int[] idIndices,
PropertyMeta propertyMeta,
PropertyMeta inversePropertyMeta)
関連エンティティマッパーを作成します。 |
protected ResultSetHandler |
createResultListResultSetHandler()
リストを返す結果セットハンドラを作成します。 |
protected ResultSetHandler |
createSingleResultResultSetHandler()
単独の値を返す結果セットハンドラを作成します。 |
protected String |
createTableAlias()
テーブル別名を作成します。 |
AutoSelect<T> |
forUpdate()
FOR UPDATEを追加します。 |
AutoSelect<T> |
forUpdate(String... propertyNames)
FOR UPDATEを追加します。 |
AutoSelect<T> |
forUpdateNowait()
FOR UPDATE NOWAITを追加します。 |
AutoSelect<T> |
forUpdateNowait(String... propertyNames)
FOR UPDATE NOWAITを追加します。 |
AutoSelect<T> |
forUpdateWait(int seconds)
FOR UPDATE WAITを追加します。 |
AutoSelect<T> |
forUpdateWait(int seconds,
String... propertyNames)
FOR UPDATE WAITを追加します。 |
protected AbstractEntityMapper |
getBaseEntityMapper(String join,
String baseJoin)
ベースのエンティティメタマッパーを返します。 |
protected EntityMeta |
getBaseEntityMeta(String join,
String base)
ベースのエンティティメタデータを返します。 |
long |
getCount()
SELECT COUNT(*)の結果である行数を返します。 |
protected EntityMapper |
getEntityMapper()
エンティティマッパーを返します。 |
protected AbstractEntityMapper |
getEntityMapper(String join)
エンティティマッパーを返します。 |
protected EntityMeta |
getEntityMeta(String join)
エンティティメタデータを返します。 |
protected EntityMeta |
getInverseEntityMeta(Class<?> relationshipClass,
String join)
関連の逆側のエンティティメタデータを返します。 |
protected PropertyMeta |
getInversePropertyMeta(EntityMeta inverseEntityMeta,
PropertyMeta relationshipPropertyMeta)
逆側のプロパティメタデータを返します。 |
protected JoinMeta |
getJoinMeta(int index)
結合メタデータを返します。 |
protected int |
getJoinMetaSize()
結合メタデータの数を返します。 |
protected String |
getLockHint(String baseName)
ロックヒントを返します。 |
protected PropertyMeta |
getPropertyMeta(EntityMeta baseEntityMeta,
String fullPropertyName,
String propertyName)
プロパティメタデータを返します。 |
protected String |
getTableAlias(String join)
テーブル別名を返します。 |
protected ValueType[] |
getValueTypes()
値タイプの配列を返します。 |
AutoSelect<T> |
hint(String hint)
ヒントを設定します。 |
AutoSelect<T> |
id(Object... idProperties)
where句の条件にIdプロパティ(主キー)を指定します。 |
AutoSelect<T> |
innerJoin(String name)
内部結合するプロパティを指定します。 |
AutoSelect<T> |
innerJoin(String name,
boolean fetch)
内部結合するプロパティを指定します。 |
AutoSelect<T> |
join(String name,
JoinType joinType)
結合するプロパティを指定します。 |
AutoSelect<T> |
join(String name,
JoinType joinType,
boolean fetch)
結合するプロパティを指定します。 |
AutoSelect<T> |
leftOuterJoin(String name)
左外部結合するプロパティを指定します。 |
AutoSelect<T> |
leftOuterJoin(String name,
boolean fetch)
左外部結合するプロパティを指定します。 |
AutoSelect<T> |
orderBy(String orderBy)
ソート順を追加します。 |
protected void |
prepare(String methodName)
クエリの準備をします。 |
protected void |
prepareCondition(String name,
Object value)
条件を準備します。 |
protected void |
prepareConditions()
where句の条件を準備します。 |
protected void |
prepareCriteria()
クライテリアの準備をします。 |
protected void |
prepareEntity(EntityMeta em,
String tableAlias,
List<PropertyMapper> propertyMapperList,
List<Integer> idIndexList)
エンティティの準備をします。 |
protected EntityMeta |
prepareEntityMeta(Class<?> entityClass,
String join)
エンティティメタデータを準備します。 |
protected void |
prepareForUpdate()
FOR UPDATE句を準備します。 |
protected void |
prepareIdVersion()
IDプロパティ及びバージョンを準備します。 |
protected void |
prepareJoin(JoinMeta joinMeta)
結合の準備をします。 |
protected void |
prepareJoins()
結合の準備をします。 |
protected void |
prepareOrderBy()
order by句の準備をします。 |
protected void |
prepareParams()
パラメータを準備します。 |
protected void |
prepareParams(String name,
Object value)
パラメータを準備します。 |
protected void |
prepareSql()
SQLを準備します。 |
protected String |
prepareTableAlias(String join)
テーブル別名を準備します。 |
protected void |
prepareTarget()
対象エンティティの準備をします。 |
protected void |
setupForUpdateTargets(String[] propertyNames)
SELECT ~ FOR UPDATEの対象となるプロパティを準備します |
protected String[] |
splitBaseAndProperty(String name)
関連名をベースとプロパティに分離します。 |
protected Pair<String,String> |
toAliasPair(String baseName,
String propertyName)
SELECT ~ FOR UPDATEの対象となるテーブルエイリアスとカラムエイリアスのペアを返します。 |
protected int[] |
toIdIndexArray(List<Integer> idIndexList)
識別子のインデックスのリストをintの配列に変換します。 |
protected PropertyMapperImpl[] |
toPropertyMapperArray(List<PropertyMapper> propertyMapperList)
プロパティマッパーの配列に変換します。 |
protected String |
toSql()
SQLに変換します。 |
AutoSelect<T> |
version(Object versionProperty)
where句の条件にバージョンプロパティを指定します。 |
AutoSelect<T> |
where(Map<String,? extends Object> conditions)
where句の条件を指定します。 |
AutoSelect<T> |
where(String criteria,
Object... params)
where句の条件を指定します。 |
AutoSelect<T> |
where(Where where)
where句の条件を指定します。 |
クラス org.seasar.extension.jdbc.query.AbstractSelect から継承されたメソッド |
---|
convertLimitSql, createResultSet, disallowNoResult, fetchSize, getBaseClass, getCursorPreparedStatement, getFetchSize, getLimit, getMaxRows, getOffset, getPreparedStatement, getResultList, getResultListInternal, getSingleResult, getSingleResultInternal, iterate, iterateInternal, limit, lob, maxRows, offset, setupPreparedStatement, temporal |
クラス org.seasar.extension.jdbc.query.AbstractQuery から継承されたメソッド |
---|
addParam, addParam, addParam, addParam, callerClass, callerMethodName, getCallerClass, getCallerMethodName, getExecutedSql, getJdbcManager, getParam, getParamClasses, getParamSize, getParamValues, getParamValueTypes, getQueryTimeout, getValueType, handleResultSet, logSql, logSql, prepareCallerClassAndMethodName, prepareInParams, queryTimeout, resetParams |
クラス java.lang.Object から継承されたメソッド |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
インタフェース org.seasar.extension.jdbc.Select から継承されたメソッド |
---|
disallowNoResult, fetchSize, getResultList, getSingleResult, iterate, limit, lob, maxRows, offset, temporal |
インタフェース org.seasar.extension.jdbc.Query から継承されたメソッド |
---|
callerClass, callerMethodName, queryTimeout |
フィールドの詳細 |
---|
protected List<JoinMeta> joinMetaList
protected int tableIndex
protected Map<String,String> tableAliasMap
protected Map<String,EntityMeta> entityMetaMap
protected String entityName
protected boolean count
true
protected SelectClause selectClause
protected FromClause fromClause
protected WhereClause whereClause
protected OrderByClause orderByClause
protected String orderBy
protected String forUpdate
protected SelectForUpdateType forUpdateType
protected Map<String,String> forUpdateTargets
protected int forUpdateWaitSeconds
protected String hint
protected List<ValueType> valueTypeList
protected int selectListIndex
protected Map<String,AbstractEntityMapper> entityMapperMap
protected Map<String,? extends Object> conditions
protected String criteria
protected Object[] criteriaParams
protected String[] criteriaPropertyNames
protected List<PropertyMeta> idPropertyMetaList
protected Object[] idProperties
protected PropertyMeta versionPropertyMeta
protected Object versionProperty
コンストラクタの詳細 |
---|
public AutoSelectImpl(JdbcManagerImplementor jdbcManager, Class<T> baseClass)
AutoSelectImpl
を作成します。
jdbcManager
- 内部的なJDBCマネージャbaseClass
- ベースクラスメソッドの詳細 |
---|
public AutoSelect<T> innerJoin(String name)
AutoSelect
の記述: 指定したエンティティはフェッチされます。
AutoSelect<T>
内の innerJoin
name
- 内部結合する関連のプロパティ名
JoinMeta
,
AutoSelect.join(String, JoinType)
public AutoSelect<T> innerJoin(String name, boolean fetch)
AutoSelect
の記述:
AutoSelect<T>
内の innerJoin
name
- 内部結合する関連のプロパティ名fetch
- 関連するエンティティをフェッチするかどうか。
AutoSelect.join(String, JoinType, boolean)
public AutoSelect<T> leftOuterJoin(String name)
AutoSelect
の記述: 指定したエンティティはフェッチされます。
AutoSelect<T>
内の leftOuterJoin
name
- 左外部結合する関連のプロパティ名
JoinMeta
,
AutoSelect.join(String, JoinType)
public AutoSelect<T> leftOuterJoin(String name, boolean fetch)
AutoSelect
の記述:
AutoSelect<T>
内の leftOuterJoin
name
- 左外部結合する関連のプロパティ名fetch
- 関連するエンティティをフェッチするかどうか。
AutoSelect.join(String, JoinType, boolean)
public AutoSelect<T> join(String name, JoinType joinType)
AutoSelect
の記述: 指定したエンティティはフェッチされます。
AutoSelect<T>
内の join
name
- 結合するプロパティ名joinType
- 結合タイプ
AutoSelect.join(String, JoinType, boolean)
public AutoSelect<T> join(String name, JoinType joinType, boolean fetch)
AutoSelect
の記述:
AutoSelect<T>
内の join
name
- 結合するプロパティ名。
ネストしている場合は、aaa.bbb
のように.で区切ります。
aaa.bbb
を指定する場合は、先にベースの結合(aaa
)を指定する必要があります。
joinType
- 結合タイプfetch
- 関連するエンティティをフェッチするかどうか。
protected int getJoinMetaSize()
protected JoinMeta getJoinMeta(int index)
index
- 位置
protected void prepare(String methodName)
AbstractQuery
の記述:
AbstractQuery<AutoSelect<T>>
内の prepare
methodName
- メソッド名protected void prepareTarget()
protected void prepareEntity(EntityMeta em, String tableAlias, List<PropertyMapper> propertyMapperList, List<Integer> idIndexList)
em
- エンティティメタデータtableAlias
- テーブル別名propertyMapperList
- プロパティマッパーのリストidIndexList
- 識別子のインデックスのリストprotected String getTableAlias(String join)
join
- 結合名
protected String createTableAlias()
protected String prepareTableAlias(String join)
join
- 結合名
protected EntityMeta getEntityMeta(String join)
join
- 結合名
protected EntityMeta prepareEntityMeta(Class<?> entityClass, String join)
entityClass
- エンティティクラスjoin
- 結合名
protected ValueType[] getValueTypes()
protected PropertyMapperImpl[] toPropertyMapperArray(List<PropertyMapper> propertyMapperList)
propertyMapperList
- プロパティマッパーのリスト
protected int[] toIdIndexArray(List<Integer> idIndexList)
idIndexList
-
protected AbstractEntityMapper getEntityMapper(String join)
join
- 結合名
protected void prepareJoins()
prepareJoin(JoinMeta)
protected void prepareJoin(JoinMeta joinMeta)
joinMeta
- 結合メタデータprotected String[] splitBaseAndProperty(String name)
関連名をベースとプロパティに分離します。
aaa.bbb.ccc
ならベースがaaa.bbb
、プロパティがccc
になります。
name
- 関連名
protected EntityMeta getBaseEntityMeta(String join, String base) throws BaseJoinNotFoundRuntimeException
join
- 結合名base
- ベースの結合名
BaseJoinNotFoundRuntimeException
- ベースの結合が見つからない場合。protected AbstractEntityMapper getBaseEntityMapper(String join, String baseJoin) throws BaseJoinNotFoundRuntimeException
join
- 結合名baseJoin
- ベースの結合名
BaseJoinNotFoundRuntimeException
- ベースの結合が見つからない場合。protected PropertyMeta getPropertyMeta(EntityMeta baseEntityMeta, String fullPropertyName, String propertyName) throws RuntimeException
baseEntityMeta
- ベースのエンティティメタデータfullPropertyName
- 全体のプロパティ名propertyName
- プロパティ名
RuntimeException
- 実行時例外が発生した場合。protected EntityMeta getInverseEntityMeta(Class<?> relationshipClass, String join) throws RuntimeException, JoinDuplicatedRuntimeException
relationshipClass
- 関連クラスjoin
- 結合名
RuntimeException
- 実行時例外が発生した場合。
JoinDuplicatedRuntimeException
- 結合が重複している場合。protected PropertyMeta getInversePropertyMeta(EntityMeta inverseEntityMeta, PropertyMeta relationshipPropertyMeta)
inverseEntityMeta
- 逆側のエンティティメタデータrelationshipPropertyMeta
- 関連のプロパティメタデータ
protected AbstractRelationshipEntityMapper createRelationshipEntityMapper(Class<?> relationshipClass, PropertyMapper[] propertyMappers, int[] idIndices, PropertyMeta propertyMeta, PropertyMeta inversePropertyMeta)
relationshipClass
- 関連クラスpropertyMappers
- プロパティマッパーの配列idIndices
- 識別子のインデックスの配列propertyMeta
- 関連のプロパティメタデータinversePropertyMeta
- 逆側の関連のプロパティメタデータ
protected String toSql()
public AutoSelect<T> where(String criteria, Object... params)
AutoSelect
の記述:
AutoSelect<T>
内の where
criteria
- クライテリアparams
- パラメータの配列
パラメータの配列の要素がDate
、Calendar
のいずれか場合、Parameter
に定義されたメソッドによりパラメータの時制を指定できます。
パラメータの配列の要素がString
、byte[]
、Serializable
のいずれかの場合、Parameter
に定義されたメソッドによりパラメータをラージオブジェクトとして扱えます。
Parameter
public AutoSelect<T> where(Where where)
AutoSelect
の記述:
AutoSelect<T>
内の where
where
- where句のビルダー
public AutoSelect<T> where(Map<String,? extends Object> conditions)
AutoSelect
の記述:
AutoSelect<T>
内の where
conditions
- where句の条件です。
Mapのキーにはプロパティ名、値には条件値を指定します。
例えば、map.put("id", 1)
と指定した場合、
id = ?
という条件になり、バインド変数が1になります。
値がnullならwhere句には追加されません。
map.put("name", null)
と指定した場合、
where句に条件は追加されないという意味です。
なぜこのような仕様になっているかというと検索条件の入力画面で 条件を組み立てるときに、入力値があるものだけ 条件に追加するケースを便利に扱うためです。
複数の条件が指定された場合は、and
で結合されます。
結合先のプロパティはキーに結合名.プロパティ名と指定します。 ネストした結合も指定することができます。
例えば、Departmentの検索で一対多の関連であるemployeesのnameプロパティを指定する場合、 キーに"employees.name"と指定します。
Employeeの検索で多対一であるdepartmentのnameプロパティを指定する場合、 キーに"department.name"と指定します。
等価(=)以外の条件を指定する場合、キーにプロパティ名_サフィックスを指定します。 サフィックスによってどのような条件になるのかが決まります。
サフィックスにはEQ(=)、NE(<>)、LT(<)、LE(<=)、 GT(>)、GE(>=)、IN(in)、NOT_IN(not in)、LIKE(like '?')、 STARTS(like '?%')、ENDS(like '%?')、CONTAINS(like '%?%')、 IS_NULL(is null)、IS_NOT_NULL(is not null)を指定することができます。
IN、NOT_INの場合、値には配列、リストを指定します。 値がnullもしくは要素の数がゼロの場合条件には追加されません。
IS_NULL、IS_NOT_NULLの場合、値にはBooleanを指定します。 例えば、map.put("hoge_IS_NOT_NULL", true)
の場合、
条件はhoge is not null
になります。
値がnullもしくはfalseだった場合、条件には追加されません。
public AutoSelect<T> id(Object... idProperties)
AutoSelect
の記述:
AutoSelect<T>
内の id
idProperties
- 主キーの値の並び
public AutoSelect<T> version(Object versionProperty)
AutoSelect
の記述:
AutoSelect<T>
内の version
versionProperty
- バージョン
public long getCount()
AutoSelect
の記述:
AutoSelect<T>
内の getCount
protected void prepareConditions()
protected void prepareCondition(String name, Object value)
name
- プロパティ名value
- プロパティの値valueList
- 値のリストvalueClassList
- 値のクラスのリストprotected void prepareCriteria()
protected void prepareIdVersion()
protected void prepareParams()
protected void prepareParams(String name, Object value)
name
- パラメータ名value
- パラメータ値protected void prepareSql()
protected ResultSetHandler createResultListResultSetHandler()
AbstractSelect
の記述:
AbstractSelect<T,AutoSelect<T>>
内の createResultListResultSetHandler
protected ResultSetHandler createSingleResultResultSetHandler()
AbstractSelect
の記述:
AbstractSelect<T,AutoSelect<T>>
内の createSingleResultResultSetHandler
protected ResultSetHandler createIterateResultSetHandler(IterationCallback<T,?> callback)
AbstractSelect
の記述:
AbstractSelect<T,AutoSelect<T>>
内の createIterateResultSetHandler
callback
- 反復コールバック
protected EntityMapper getEntityMapper()
public AutoSelect<T> orderBy(String orderBy)
AutoSelect
の記述:
AutoSelect<T>
内の orderBy
protected void prepareOrderBy()
protected String convertCriteria(String str)
str
- クライテリア
protected String convertEntityNameToTableAlias(String str)
str
- 入力文字列
public AutoSelect<T> forUpdate()
AutoSelect
の記述:
AutoSelect<T>
内の forUpdate
public AutoSelect<T> forUpdate(String... propertyNames)
AutoSelect
の記述:
AutoSelect<T>
内の forUpdate
propertyNames
- ロック対象のプロパティ名の並び
public AutoSelect<T> forUpdateNowait()
AutoSelect
の記述:
AutoSelect<T>
内の forUpdateNowait
public AutoSelect<T> forUpdateNowait(String... propertyNames)
AutoSelect
の記述:
AutoSelect<T>
内の forUpdateNowait
propertyNames
- ロック対象のプロパティ名の並び
public AutoSelect<T> forUpdateWait(int seconds)
AutoSelect
の記述:
AutoSelect<T>
内の forUpdateWait
seconds
- ロックを獲得できるまでの最大待機時間(秒単位)
public AutoSelect<T> forUpdateWait(int seconds, String... propertyNames)
AutoSelect
の記述:
AutoSelect<T>
内の forUpdateWait
seconds
- ロックを獲得できるまでの最大待機時間(秒単位)propertyNames
- ロック対象のプロパティ名の並び
public AutoSelect<T> hint(String hint)
AutoSelect
の記述:
AutoSelect<T>
内の hint
hint
- ヒント
protected void prepareForUpdate()
protected String getLockHint(String baseName)
baseName
- ベース名
protected void setupForUpdateTargets(String[] propertyNames)
propertyNames
- SELECT ~ FOR UPDATEの対象となるプロパティ名の並びprotected Pair<String,String> toAliasPair(String baseName, String propertyName)
baseName
- ベース名propertyName
- プロパティ名
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |