title: no values persisted in database when running spring boot JPA test
body: <p>I was looking at solutions of mapping column default value in <code>spring-data-jpa</code> which lead me to documentation of <code>@ColumnDefault</code> annotation; and I wanted to try it out. So I updated an entity where we needed default values (today this is handled via a schema.sql where we define additional column behaviours) like so:</p>
  
  <pre><code>@Entity
  @Getter
  @Setter
  @ToString
  @DynamicInsert
  @NoArgsConstructor
  @Relation(collectionRelation = "customers")
  public class Customer extends Organisation implements Identifiable&lt;Long&gt;, Serializable {
  
    private static final long serialVersionUID = 8101819808147191270L;
  
    @Column(nullable = false, updatable = false, length = 3)
    @ColumnDefault("'INR'")
    private String currency;
  
    @Column(scale = 2)
    @ColumnDefault("0.10")
    private Double tds;
  
    @Column(nullable = false, updatable = false, length = 3)
    @ColumnDefault("'INV'")
    private String invoicePrefix;
  </code></pre>
  
  <p>Now since I'm using the <code>@ColumnDefault</code> I expect that default values are configured for the column, which they are when I look at the database. However, when I run a test to insert values; the defaults fields are <code>null</code>. I configured Postgresql for the test (as production will be in Postgresql); While the DDL for table in Postgresql shows default values are added to 
  table definition</p>
  
  <pre><code>CREATE TABLE data_api_it.customer
  (
      currency character varying(3) COLLATE pg_catalog."default" NOT NULL DEFAULT 'INR'::character varying,
      invoice_prefix character varying(3) COLLATE pg_catalog."default" NOT NULL DEFAULT 'INV'::character varying,
      tds double precision DEFAULT 0.10,
      id bigint NOT NULL,
      CONSTRAINT customer_pkey PRIMARY KEY (id),
      CONSTRAINT fk3afgab8nfy6ykn6b70uuh9v59 FOREIGN KEY (id)
          REFERENCES data_api.organisation (id) MATCH SIMPLE
          ON UPDATE NO ACTION
          ON DELETE NO ACTION
  )
  </code></pre>
  
  <p>Here's the test that fails</p>
  
  <pre><code>@Slf4j
  @RunWith(SpringRunner.class)
  @DataJpaTest(showSql = false)
  @ContextConfiguration(classes = { DataApiJpaConfiguration.class })
  @TestPropertySource(locations = {"classpath:application-it.properties","classpath:application-test.properties"})
  @AutoConfigureTestDatabase(replace = Replace.NONE)
  public class CustomerRepositoryIntegrationTest {
  
    @Autowired
    private CustomerRepository customerRepository;
  
    @Test
    public void testPrePersistAddsMandatoryFields() {
  
      Customer bhau = new Customer();
      bhau.setName("Bhau &amp; Sons Pvt. Ltd.");
      bhau.setDomain(RandomStringUtils.randomAlphanumeric(8));
      bhau = customerRepository.saveAndFlush(bhau);
      Customer badaBhau = customerRepository.findById(bhau.getId()).get();
      assertThat(badaBhau.getTds().doubleValue()).isEqualTo(0.10);
      assertThat(badaBhau.getInvoicePrefix()).isEqualTo("INV");
      assertThat(badaBhau.getCurrency()).isEqualTo("INR");
    }
  
  }
  </code></pre>
  
  <p>The failure is a <code>NullPointerException</code> at <code>assertThat(badaBhau.getTds().doubleValue()).isEqualTo(0.10);</code> when I run on debug I notice that <code>badaBhau</code> indeed doesn't have the default values set when queried from the database. I then paused after the line when it persists <code>bhau</code>; browsed test database configured and noticed that the <code>bhau</code> entity isn't even saved to the database in the first place.</p>
  
  <p>I also ran the app with Postgesql Dev DB trying to hit the API url for saving customer with the JSON data </p>
  
  <pre><code>{
      "name":"Minty and Sons Pvt. Ltd.",
      "pan": "AASONAL123",
      "domain": "xy123456"
  }
  </code></pre>
  
  <p>this call succeeds in creating the record of course with default values <code>INR</code>, <code>INV</code>, <code>0.10</code> for <code>currency</code>, <code>invoice_prefix</code> and <code>tds</code> respectively.</p>
  
  <p>So while I understand and like how <code>@ColumnDefault</code> solves the default value issue for me; I'm utterly confused as to what why the test fails (or what am I doing wrong)</p>