I'm trying to use a UUID for a primary key using JPA 2 (EclipseLink). I'm using PostgreSQL as the database. I have my entity declared as follows: I have an Employee table with its PK set as a UUID. I have a JPA Entity mapping to the employee table, which looks like this:
@Entity
public class Employee {
@Id
private String id;
...
...
}
When I call EntityManager.find(Employee.class, id)
I get an exception from postgres:
Internal Exception: org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
I have also tried changing the id in the Employee class to java.util.UUID, but then I get the following (very similar error):
Internal Exception: org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = bytea Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
I'm really not sure how to go about fixing this... anyone have any ideas?
Thanks!