Получить корректный boolean из базы данных
Есть сущность:
@Entity
@Table(name = "deposits")
public class Deposit {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "balance")
private double balance;
@Column(name = "active")
private boolean active;
public Deposit() { }
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
Перед записью в базу данных значение устанавливается TRUE (запись вносится корректно):
| id | balance | active |
|---|---|---|
| 1 | 0 | true |
| 2 | 0 | true |
Но при извлечении из БД все время извлекается только как FALSE.
(Метод извлечения из БД)
public List<Deposit> getAll() {
return jdbcTemplate.query("SELECT * FROM deposits", new RowMapper<Deposit>() {
@Override
public Deposit mapRow(ResultSet rs, int rowNum) throws SQLException {
Deposit deposit = new Deposit();
deposit.setId(rs.getLong(1));
deposit.setBalance(rs.getDouble(2));
deposit.setActive(rs.getBoolean(3));
System.out.println(deposit.isActive());
return deposit;
}
});
}