samedi 25 juillet 2020

Hibernate ColumnTransformer and DataJpaTest

I do have a mysql database. That database reads and writes by hibernate and uses field encryption. The application is running on spring boot.

    @ColumnTransformer(
            read = "AES_DECRYPT(message, 'secret')",
            write = "AES_ENCRYPT(?, 'secret')"
    )
    @Column(
            columnDefinition = "varbinary(5120)"
    )
    private String field;

When writing unit tests I get an exception because these test is running on embedded h2 and the encryption methods are mysql based.

@RunWith(SpringRunner.class)
@DataJpaTest

I found this solution, but it does not work for me: How to Ignore Certain Fields in unit tests, Hibernate

Is there any way to test this behaviour and ignoring encryption and decryption in test configuration?

regards, Moritz

Aucun commentaire:

Enregistrer un commentaire