javaspringjdbctemplatenotserializableexception

spring jdbctemplate.query method gives me this exception invalid argument java.io Not Serializable exception


[enter image description here][1] this is my code where i got java.ioNotSerializabale Exception when i run below query i got this exception

java.io.NotSerializableException

my pojo class is here public class ProjectHelper implements Serializable {

private String name;
private String description;
private String company;
private String category;
private List<UserRegister> usersRegisterList;

private String startDate;

And this is my DaoImpl method where i got error "java.io.NotSerializableException"

@Override
public GenericModal getProjects(User email) throws SQLException {

    String sql = "select p.project_name, p.project_description, p.company,                      p.start_date, p.end_date, " +
            "p.category f.task, f.milestones, f.billing, f.time_log, f.messages, f.features_id, f.files, u.firstName" +
            "u.lastname, u.email" +
            " from project as p" +
            "join userprojectrelation as upr" +
            "on p.project_id=upr.project_id " +
            "join users as u" +
            "on u.UserId=upr.user_id" +
            "join features as f " +
            "on f.project_id=p.project_id" +
            "where u.email=?";
    int status = 0;
    GenericModal genericModal=new GenericModal();

    try {
        List<ProjectHelper> projectHelper=jdbcTemplate.query(sql,new Object[]{email},new ProjectHelperMapper());
        if (projectHelper.isEmpty()) {
            return null;
        } else {
            genericModal.setObject(projectHelper);
        }
       // return genericModal;
    } catch (Exception ex) {
        genericModal.setException(ex.getMessage());
    }

    return genericModal;
}

Solution

  • It's probably UserRegister that isn't Serializable. If you want to serialize a class, all of it's components (fields) must also be serializable, unless you implement custom serialization methods or mark the fields as transient.