|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
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 String |
criteria
クライテリアです。 |
protected Map<String,AbstractEntityMapper> |
entityMapperMap
エンティティマッパーのマップです。 |
protected Map<String,EntityMeta> |
entityMetaMap
エンティティメタデータのマップです。 |
protected String |
entityName
エンティティ名です。 |
protected FromClause |
fromClause
from句です。 |
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 WhereClause |
whereClause
where句です。 |
クラス org.seasar.extension.jdbc.query.AbstractSelect から継承されたフィールド |
---|
baseClass, fetchSize, limit, maxRows, offset |
クラス org.seasar.extension.jdbc.query.AbstractQuery から継承されたフィールド |
---|
callerClass, callerMethodName, executedSql, jdbcManager, logger, paramList, queryTimeout |
コンストラクタの概要 | |
---|---|
AutoSelectImpl(JdbcManager jdbcManager,
Class<T> baseClass)
AutoSelectImpl を作成します。 |
メソッドの概要 | |
---|---|
protected void |
addCondition(String condition,
Object value,
Class<?> paramClass)
条件を追加します。 |
protected void |
addInCondition(String condition,
Object values,
Class<?> paramClass,
int size)
in、not in用の条件を追加します。 |
protected String |
convertCriteria(String str)
プロパティ名で記述されたクライテリアをカラム名に変換します。 |
protected AbstractRelationshipEntityMapper |
createRelationshipEntityMapper(Class<?> relationshipClass,
PropertyMapper[] propertyMappers,
int[] idIndices,
PropertyMeta propertyMeta,
PropertyMeta inversePropertyMeta)
関連エンティティマッパーを作成します。 |
protected ResultSetHandler |
createResultListResultSetHandler()
リストを返す結果セットハンドラを作成します。 |
protected ResultSetHandler |
createSingleResultResultSetHandler()
単独の値を返す結果セットハンドラを作成します。 |
protected String |
createTableAlias()
テーブル別名を作成します。 |
protected AbstractEntityMapper |
getBaseEntityMapper(String join,
String baseJoin)
ベースのエンティティメタマッパーを返します。 |
protected EntityMeta |
getBaseEntityMeta(String join,
String base)
ベースのエンティティメタデータを返します。 |
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 PropertyMeta |
getPropertyMeta(EntityMeta baseEntityMeta,
String fullPropertyName,
String propertyName)
プロパティメタデータを返します。 |
protected String |
getTableAlias(String join)
テーブル別名を返します。 |
protected ValueType[] |
getValueTypes()
値タイプの配列を返します。 |
AutoSelect<T> |
join(String name)
結合するプロパティを指定します。 |
AutoSelect<T> |
join(String name,
boolean fetch)
結合するプロパティを指定します。 |
AutoSelect<T> |
join(String name,
JoinType joinType)
結合するプロパティを指定します。 |
AutoSelect<T> |
join(String name,
JoinType joinType,
boolean fetch)
結合するプロパティを指定します。 |
AutoSelect<T> |
orderBy(String orderBy)
ソート順を追加します。 |
protected void |
prepare(String methodName)
クエリの準備をします。 |
protected void |
prepareCondition(String name,
Object value,
List<Object> valueList,
List<Class<?>> valueClassList)
条件を準備します。 |
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 |
prepareJoin(JoinMeta joinMeta)
結合の準備をします。 |
protected void |
prepareJoins()
結合の準備をします。 |
protected void |
prepareOrderBy()
order by句の準備をします。 |
protected void |
prepareSql()
SQLを準備します。 |
protected String |
prepareTableAlias(String join)
テーブル別名を準備します。 |
protected void |
prepareTarget()
対象エンティティの準備をします。 |
protected String[] |
splitBaseAndProperty(String name)
関連名をベースとプロパティに分離します。 |
protected int[] |
toIdIndexArray(List<Integer> idIndexList)
識別子のインデックスのリストをintの配列に変換します。 |
protected PropertyMapperImpl[] |
toPropertyMapperArray(List<PropertyMapper> propertyMapperList)
プロパティマッパーの配列に変換します。 |
protected String |
toSql()
SQLに変換します。 |
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, fetchSize, getBaseClass, getCursorPreparedStatement, getFetchSize, getLimit, getMaxRows, getOffset, getPreparedStatement, getResultList, getResultListInternal, getSingleResult, getSingleResultInternal, limit, maxRows, offset, setupPreparedStatement |
クラス org.seasar.extension.jdbc.query.AbstractQuery から継承されたメソッド |
---|
addParam, addParam, addParam, addParam, callerClass, callerMethodName, getCallerClass, getCallerMethodName, getExecutedSql, getJdbcManager, getParam, getParamClasses, getParamSize, getParamValues, 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 から継承されたメソッド |
---|
fetchSize, getResultList, getSingleResult, limit, maxRows, offset |
インタフェース 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 SelectClause selectClause
protected FromClause fromClause
protected WhereClause whereClause
protected OrderByClause orderByClause
protected String orderBy
protected List<ValueType> valueTypeList
protected int selectListIndex
protected Map<String,AbstractEntityMapper> entityMapperMap
protected Map<String,? extends Object> conditions
protected String criteria
コンストラクタの詳細 |
---|
public AutoSelectImpl(JdbcManager jdbcManager, Class<T> baseClass)
AutoSelectImpl
を作成します。
jdbcManager
- JDBCマネージャbaseClass
- ベースクラスメソッドの詳細 |
---|
public AutoSelect<T> join(String name)
AutoSelect
の記述: 結合するプロパティを指定します。
デフォルトの結合タイプは左外部結合で、 指定したエンティティはフェッチされます。
AutoSelect<T>
内の join
name
- 結合するプロパティ名
JoinMeta
,
AutoSelect.join(String, JoinType)
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, boolean fetch)
AutoSelect
の記述: 結合するプロパティを指定します。
デフォルトの結合タイプは左外部結合です。
AutoSelect<T>
内の join
name
- 結合するプロパティ名fetch
- 関連するエンティティをフェッチするかどうか。
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(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> where(String criteria, Object... params)
AutoSelect
の記述:
AutoSelect<T>
内の where
criteria
- クライテリアparams
- パラメータの配列
public AutoSelect<T> where(Where where)
AutoSelect
の記述:
AutoSelect<T>
内の where
where
- where句のビルダー
protected void prepareConditions()
protected void prepareCondition(String name, Object value, List<Object> valueList, List<Class<?>> valueClassList)
name
- プロパティ名value
- プロパティの値valueList
- 値のリストvalueClassList
- 値のクラスのリストprotected void addCondition(String condition, Object value, Class<?> paramClass)
condition
- 条件value
- パラメータの値paramClass
- パラメータのクラスprotected void addInCondition(String condition, Object values, Class<?> paramClass, int size)
condition
- 条件values
- パラメータの値の配列paramClass
- パラメータのクラスsize
- 配列のサイズprotected void prepareCriteria()
protected void prepareSql()
protected ResultSetHandler createResultListResultSetHandler()
AbstractSelect
の記述:
AbstractSelect<T,AutoSelect<T>>
内の createResultListResultSetHandler
protected ResultSetHandler createSingleResultResultSetHandler()
AbstractSelect
の記述:
AbstractSelect<T,AutoSelect<T>>
内の createSingleResultResultSetHandler
protected EntityMapper getEntityMapper()
public AutoSelect<T> orderBy(String orderBy)
AutoSelect
の記述:
AutoSelect<T>
内の orderBy
protected void prepareOrderBy()
protected String convertCriteria(String str)
str
- クライテリア
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |