@@ -0,0 +1,1578 @@
+package com.vladmihalcea.book.hpjp.hibernate.mapping.calculated;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractPostgreSQLIntegrationTest;%0Aimport org.hibernate.annotations.Formula;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.sql.Timestamp;%0Aimport java.time.LocalDateTime;%0Aimport java.util.Date;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class FormulaCurrentDateTest extends AbstractPostgreSQLIntegrationTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D %7B%0A            Event.class,%0A        %7D;%0A    %7D%0A%0A    @Test%0A    public void test() %7B%0A        doInJPA(entityManager -%3E %7B%0A            Event event = new Event();%0A            event.setId(1L);%0A%0A            entityManager.persist(event);%0A        %7D);%0A        doInJPA(entityManager -%3E %7B%0A            Event event = entityManager.find(Event.class, 1L);%0A%0A            assertNotNull(event.getCreatedOn());%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Event%22)%0A    @Table(name = %22event%22)%0A    public static class Event %7B%0A%0A        @Id%0A        private Long id;%0A%0A        @Formula(%22(SELECT current_date)%22)%0A        @Temporal(TemporalType.TIMESTAMP)%0A        private Date createdOn;%0A%0A        public Long getId() %7B%0A            return id;%0A        %7D%0A%0A        public void setId(Long id) %7B%0A            this.id = id;%0A        %7D%0A%0A        public Date getCreatedOn() %7B%0A            return createdOn;%0A        %7D%0A%0A        public void setCreatedOn(Date createdOn) %7B%0A            this.createdOn = createdOn;%0A        %7D%0A    %7D%0A%7D%0A

Add @Formula test with currentdate