Issue
I have this repository:
@Repository
public interface DomainRepository extends CrudRepository<Domain, String> {
Domain findByUuid(UUID uuid);
}
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name="a", schema="b")
public class Domain {
@Id
private String id;
private UUID uuid;
}
But when I do
Domain d = domainRepository.findByUuid(UUID.randomUUID());
I get PSQLException: ERROR: operator does not exist: character varying = uuid
(column type in table is VARCHAR
).
How to fix this?
Solution
Try defining the type for the field as Hibernate unable to understand the type by annotating field with @Type(type="org.hibernate.type.UUIDCharType")
@Type(type="org.hibernate.type.UUIDCharType")
private UUID id;
Answered By - Alien
Answer Checked By - Clifford M. (JavaFixing Volunteer)