I have one table in which primary column if of type uuid. The same column is referenced as foreign key in another table. When i try to insert data to foreign table from hibernate i get "Caused by: org.postgresql.util.PSQLException: ERROR: column is of type uuid but expression is of type bytea Hint: You will need to rewrite or cast the expression." Exception. If any one have encountered this issue please reply to the post.
Primary table ID generation
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Type(type = "pg-uuid")
@Id
@Column(name = "id")
public UUID getId() {
return id;
}
Foreign Table reference
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id", columnDefinition="uuid")
public Company getCompanyid() {
return companyid;
}
Error is thrown when saving data to foreign table not the primary table.