クラス DataClassRowMapper<T>
java.lang.ObjectSE
org.springframework.jdbc.core.BeanPropertyRowMapper<T>
org.springframework.jdbc.core.DataClassRowMapper<T>
- 型パラメーター:
T
- 結果の型
- 実装されたすべてのインターフェース:
RowMapper<T>
行を、指定されたマップ済みターゲットクラスの新しいインスタンスに変換する
RowMapper
実装。マップされたターゲットクラスは最上位クラスまたは static
ネストされたクラスである必要があり、列名に対応する名前付きパラメーターを持つデータクラスコンストラクター、または列名に対応するプロパティ名を持つ従来の Bean プロパティ setter メソッド (またはその組み合わせ) のいずれかを公開できます。両方の)。「データクラス」という用語は、Java レコード、Kotlin データクラス、および対応する列名にマップされることを意図した名前付きパラメーターを持つコンストラクターを持つすべてのクラスに適用されます。
データクラスコンストラクターを setter メソッドと組み合わせる場合、コンストラクター引数を介して正常にマップされたプロパティは、対応する setter メソッドを介して追加でマップされることはありません。これは、コンストラクターの引数がプロパティ setter メソッドよりも優先されることを意味します。
このクラスは BeanPropertyRowMapper
を継承するため、マップされたターゲットクラスの一般的な選択肢として機能し、マップされたクラスの setter メソッドに対してコンストラクタースタイルに柔軟に適応できることに注意してください。
このクラスは、高性能ではなく利便性を提供するように設計されていることに注意してください。最高のパフォーマンスを得るには、カスタム RowMapper
実装の使用を検討してください。
- 導入:
- 5.3
- 作成者:
- Juergen Hoeller, Sam Brannen
フィールドサマリー
クラス org.springframework.jdbc.core.BeanPropertyRowMapper から継承されたフィールド
logger
コンストラクターのサマリー
コンストラクター説明Bean スタイルの構成用に新しいDataClassRowMapper
を作成します。DataClassRowMapper
(ClassSE<T> mappedClass) 新しいDataClassRowMapper
を作成します。メソッドのサマリー
修飾子と型メソッド説明protected T
現在の行のマップされたクラスのインスタンスを作成します。protected void
initialize
(ClassSE<T> mappedClass) 指定されたクラスのマッピングメタデータを初期化します。static <T> DataClassRowMapper<T>
newInstance
(ClassSE<T> mappedClass) 新しいDataClassRowMapper
を作成する静的ファクトリメソッド。static <T> DataClassRowMapper<T>
newInstance
(ClassSE<T> mappedClass, ConversionService conversionService) 新しいDataClassRowMapper
を作成する静的ファクトリメソッド。クラス org.springframework.jdbc.core.BeanPropertyRowMapper から継承されたメソッド
getColumnValue, getColumnValue, getConversionService, getMappedClass, initBeanWrapper, isCheckFullyPopulated, isPrimitivesDefaultedForNullValue, lowerCaseName, mapRow, setCheckFullyPopulated, setConversionService, setMappedClass, setPrimitivesDefaultedForNullValue, suppressProperty, underscoreName
コンストラクターの詳細
DataClassRowMapper
public DataClassRowMapper()Bean スタイルの構成用に新しいDataClassRowMapper
を作成します。DataClassRowMapper
新しいDataClassRowMapper
を作成します。- パラメーター:
mappedClass
- 各行がマップされるクラス
メソッドの詳細
initialize
クラスからコピーされた説明:BeanPropertyRowMapper
指定されたクラスのマッピングメタデータを初期化します。- オーバーライド:
- クラス
BeanPropertyRowMapper<T>
のinitialize
- パラメーター:
mappedClass
- マッピングされたクラス
constructMappedInstance
クラスからコピーされた説明:BeanPropertyRowMapper
現在の行のマップされたクラスのインスタンスを作成します。- オーバーライド:
- クラス
BeanPropertyRowMapper<T>
のconstructMappedInstance
- パラメーター:
rs
- ResultSet をマップする (現在の行に対して事前に初期化済み)tc
- この RowMapper の変換サービスを備えた TypeConverter- 戻り値:
- マップされたクラスの対応するインスタンス
- 例外:
SQLExceptionSE
- SQLException が発生した場合
newInstance
新しいDataClassRowMapper
を作成する静的ファクトリメソッド。- パラメーター:
mappedClass
- 各行がマップされるクラス- 関連事項:
newInstance
public static <T> DataClassRowMapper<T> newInstance(ClassSE<T> mappedClass, @Nullable ConversionService conversionService) 新しいDataClassRowMapper
を作成する静的ファクトリメソッド。- パラメーター:
mappedClass
- 各行がマップされるクラスconversionService
- JDBC 値を Bean プロパティにバインドする場合はConversionService
、ない場合はnull
- 関連事項: