I have Embeddable class which look like this:
public class ClobEmbeddableValue {
...fields...
@Lob
@Type(type = "org.hibernate.type.MaterializedClobType")
@Column(name = "clobValue")
@Override
public String getValue() { return value; }
public String getChecksum() { return checksum; }
...other getters/setters...
}
and this is used in entity as
@ElementCollection
@ForeignKey(name = "fk_clob")
@CollectionTable(name = "m_clob", joinColumns = {
@JoinColumn(name = "owner_id"),
@JoinColumn(name = "owner_oid"),
@JoinColumn(name = "ownerType")})
@Cascade({org.hibernate.annotations.CascadeType.ALL})
public Set<ClobEmbeddableValue> getClobs() { return clobs; }
When I'm updating entity and/or it's clobs hibernate generates update/delete SQL query where all fields from Embeddable are present. I understand why it does this, but that is not very good in this case, because Hibernate tries to compare CLOB value with operator = Can I somehow tell hibernate to ignore field value (CLOB) and only use checksum (which was created for this purpose and it's md5 hash computed from clob, so it's good enough for comparing) in where clauses in queries? Or do you guys have other ideas how to solve this?