I have adudited table with @Lob field. Without @Audited saving object by Spring CrudRepository works ok, but when i want audit turn on i get error: PSQLException: ERROR: column "content" is of type oid but expression is of type bytea. How to resolve this ? Content column in PostgreSQL database is oid type (for both tables). On Hibernate 5.x the same configuration works, but not o Hibernate 6.x.
@Entity
@Audited
@Table(name = "up_test")
@Getter @Setter
public class UploadTestEntity extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "up_test_seq")
@TableGenerator(table = "id_generator", name = "up_test_seq", initialValue = 1, allocationSize = 1)
private Integer id;
@Lob
private byte[] content;
}
Just remove the
@Lobannotation.The Postgres JDBC driver does not support handling the
byteatype via the JDBC LOB APIssetBlob()/getBlob(). I don't know why, and it seems like something that should be supported.But on the other hand, you don't need it here. The most natural way to handle a field of type
byte[]mapping tobyteais to usesetBytes()/getBytes(), which is the job of Hibernate'sVarbinaryJdbcType.I don't know where people got the idea that they needed to use
@Lobfor this instead of just going with the default mapping forbyte[].