Why h2 not found a column

I have following problem

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Kolumna “CREATED_AT” nie istnieje Column “CREATED_AT” not found; SQL statement: insert into taco (id, created_at, name) values (null, ?, ?) [42122-200]

but in h2 console the column is present

enter image description here

i have following schema.sql code

create table if not exists Taco(
id identity,
name varchar(50) not null,
createdAt timestamp not null

and domain

package my.taco.models;

import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

public class Taco {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Size(min=5,message = "Nazwa musi składać się z przynajmniej pięciu znaków")
    private String name;

    private Date createdAt;

    @ManyToMany(targetEntity = Ingredient.class)
    @Size(min=1,message = "Musisz wybrac przynajmniej jeden składnik")
    private List<Ingredient> ingredients;

    void createdAt(){
        this.createdAt=new Date();

so what`s wrong ?


The default column name guessed by Hibernate (based on the attribute name) is CREATED_AT but yours is CREATEDAT

You can either rename the column in your database (recommended because it is more standard) or you can specify the column name to Hibernate like this :

private Date createdAt;

Leave a Reply

Your email address will not be published. Required fields are marked *