title: @PrePersist method not working or not been called
body: <p>Recently I have been into this book "Spring in Action 5th" since I need the framework for an important course work, but I have been stuck at the end of a chapter and can't go on. The problem here I think is that the method called "createdAt()" (whose task as you might imagine is to set the same called attribute of the object before persist it) which is annotated with <code>@PrePersist</code> is not been called before hibernate persist the object, so the database get it as null and throw an error.</p>
  
  <p>As said this is a spring boot project, using spring-boot-starter-web hibernate with an embedded h2database.</p>
  
  <p>The project is very simple it just has a Taco class which contains Ingredient objects. The controller is supposed to receive the "name" and "ingredients" attributes, and it does. The problem is just when trying to persist the Taco taco object in the database. I'm posting you some of the code, sorry for the lack of highlighting.</p>
  
  <pre><code>springboot version: 2.1.4.RELEASE
  com.h2database version: 1.4.196
  </code></pre>
  
  <p>Entity:</p>
  
  <pre><code>//The entity 
  @Data
  @Entity
  public class Taco {
  
     @Id
     @GenerateValue(strategy = GenerationType.AUTO)
     private Long id;
     @NotNull
     private String name
     @ManyToMany(targetEntity=Ingredient.class)
     private List&lt;Ingredient&gt; ingredients
  
     //then
     private Date createdAt;
  
     @PrePersist
     void createdAt(){
        this.createdAt = new Date();
     }
  }
  
  //The controller
  @Slf4j
  @Controller
  @Requestmapping("/design")
  @SessionAtributes("order")
  public class DesignTacoController{
     //regular repository stuff and model attributes
  
     @PostMapping
     public String processDesign(@Valid Taco taco, @Model Attribute Order order, Errors errors){
        //if error return to the view
        Taco saved = tacoRepo.save(taco);
     }
  }
  </code></pre>
  
  <p>The example is so simple that is almost obvious what to expect from the code, it just have to save the Taco object. Just before executing save() the "name" attribute is setted. When the save() method is executed it throws this well known exception:</p>
  
  <blockquote>
    <p>Sequence "HIBERNATE_SEQUENCE" not found; SQL statement: call next value for hibernate_secuence[90036-196]</p>
  </blockquote>
  
  <p>I've been told to change the generating value strategy from <code>@GeneratedValue (strategy = GenerationType.AUTO)</code> to <code>@GeneratedValue ( strategy =  GenerationType.IDENTIFY)</code>. When doing this it stop not finding the sequences but instead it throws another error:</p>
  
  <blockquote>
    <p>Column "CREATED_AT" not found; SQL statement: insert into taco(id,created_at,name) values (null,?,?) [42122-196]</p>
  </blockquote>
  
  <p>Which make me think the sequence problem is gone, but now the <code>@PrePersisted</code> method is not been called or not working. I've read some <code>Listeners</code> and <code>EventHandler</code> solutions online, but this has to be much more simpler than that i think since the book doesn't cover those advanced topic so far, anyways those solutions didn't work for me either.</p>
  
  <h2>Update</h2>
  
  <p>I don't think is a duplicated of "how to automatic create a table in jpa persistence xml file" since it refers to Spring's persistences xml file and I am working with spring boot, which has not such file so far in the project, also the missing @Table annotation was not a solution neither the jpa property values since the error given was also not the same.</p>