title: UUID support for different DB with Spring boot
body: <p>I am trying to use UUID as the primary key of my table. I am using postgresql for production and h2 for test. I am creating the table using liquibase and set this column type as UUID, which liquibase support the type for both h2 and postgres</p>
  <pre><code>&lt;column name=&quot;uuid&quot; type=&quot;UUID&quot;&gt;
  
   @Id
   private UUID uuid;
  </code></pre>
  <p>I got to two questions/issues when I try to save a record using JPA with spring-boot. For Postgres, I will get the following error</p>
  <pre><code>org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = bytea
  </code></pre>
  <p>I understand this was because JPA doesn't know which type should be converted to from Java UUID type. Some people suggest using  @Type(type=&quot;org.hibernate.type.PostgresUUIDType&quot;) on the UUID filed in the entity class. However, this doesn't change anything for me and I still got the same error. Not sure what I have missed.</p>
  <p>A further question is how to make it also working with h2 when I switch to run the test config, as the annotation is specific to the Postgres.  Any suggestion please?</p>