string、int、および boolean フィールドを持つクラスがあります。私はゲッターとセッターを宣言しました。
public class SomeClass {
private int id;
private String description;
private boolean active;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
私は BeanPropertyRowMapper で、Oracle DB からすべてのオブジェクトを取得します。
@Override
public List<Destination> getAll() {
List<SomeClass> objs = jdbcTemplate.query(
myQuery, new BeanPropertyRowMapper<SomeClass>(SomeClass.class));
return objs;
}
デバッグがオンになっている場合、次のように表示されます。
[3/14/13 10:02:09:202 EDT] 00000018 SystemOut O DEBUG BeanPropertyRowMapper - Mapping column 'ID' to property 'id' of type int
[3/14/13 10:02:09:202 EDT] 00000018 SystemOut O DEBUG BeanPropertyRowMapper - Mapping column 'DESCRIPTION' to property 'description' of type class java.lang.String
そして、アクティブなマップに失敗します。アクティブは、DB で 1 バイトの CHAR として定義され、値は「Y」または「N」です。BeanPropertyRowMapper を使用して、「Y」や「N」などの値をブール値に正常に変換する最良の方法は何ですか?