Spring: java.io.NotSerializableException: MapSqlParameterSource

0

I'm trying a simple insert in the base with Spring JdbcTemplate mapping the query parameters with the MapSqlParamaterSource and I'm taking error as per the data below:

public void adiciona(Conta conta) {
    String sql = "insert into contas (descricao, paga, valor, tipo) values (:descricao,:paga,:valor,:tipo)";
    MapSqlParameterSource pss = new MapSqlParameterSource();
    pss.addValue("descricao", conta.getDescricao());
    pss.addValue("paga", "true");
    pss.addValue("valor", conta.getValor());
    pss.addValue("tipo", conta.getTipo());

    getJdbcTemplate().update(sql, pss);     
}

Error log:

mar 22, 2015 12:16:00 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [spring mvc] in context with path [/contas] threw exception [Request processing failed; nested exception is org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [insert into contas (descricao, paga, valor, tipo) values (:descricao,:paga,:valor,:tipo)]; Invalid argument value: java.io.NotSerializableException; nested exception is java.sql.SQLException: Invalid argument value: java.io.NotSerializableException] with root cause
java.io.NotSerializableException: org.springframework.jdbc.core.namedparam.MapSqlParameterSource

Java Bean:

public class Conta implements Serializable{

    private static final long serialVersionUID = 4678852901357132238L;

    private Long id;
    private String descricao;
    private boolean paga;
    private double valor;
    private Calendar dataPagamento;
    private TipoDaConta tipo;

    //getters and setters

Can someone tell me how to solve this problem?

    
asked by anonymous 22.03.2015 / 16:20

0 answers