Java – Error value of type SqlExceptionHelper.logExceptions int: WRAP

Error value of type SqlExceptionHelper.logExceptions int: WRAP… here is a solution to the problem.

Error value of type SqlExceptionHelper.logExceptions int: WRAP

Hello, I followed Spring in the 5th edition of the Action book and I had a problem when I wanted to get the parameters from the Ingredient table. In the following method, I tried populating the list with ingredientRepository.findAll():

public String showDesignForm(Model model){
    List<Ingredient> ingredients = new ArrayList<>();

Type[] types = Ingredient.Type.values();
    for (Type type : types){
                filterByType(ingredients, type));
    model.addAttribute("taco", new Taco());
    return "welcomePage";

However, I encountered the following error:

org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute query; SQL [select as id1_0_, as name2_0_, ingredient0_.type as type3_0_ from Ingredient ingredient0_]; nested exception is org.hibernate.exception.DataException: could not execute query] with root cause
    org.postgresql.util.PSQLException: Bad value for type int : WRAP

This is what my constituent entity looks like:

@NoArgsConstructor(access=AccessLevel.PRIVATE, force=true)
public class Ingredient {
    @Column(name = "id", columnDefinition = "varchar(4)")
    private final String id;
    @Column(columnDefinition = "varchar(25)")
    private final String name;
    @Column(columnDefinition = "varchar")
    private final Type type;
    public static enum Type {

How do I fix it? Thanks in advance


Enumerations with JPA can be obtained using different methods using @Enumerated annotations.

It seems that by default, values are obtained by ordinal values, which is why this error occurs because you store the value as a string.

Try the following to tell JPA that your enumeration value is persisted as a String:

@Column(columnDefinition = "varchar")
private final Type type;

Related Problems and Solutions