I have an element collection on my class:
public class InstancePdo implements Comparable<InstancePdo> {
@Id
@Column(name = COLUMN_NAME_ID, columnDefinition = "UUID")
private UUID id;
@Id
@Column(name = COLUMN_NAME_VERSION, columnDefinition = "int")
private int version = -1;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "settings", joinColumns = {
@JoinColumn(name = COLUMN_NAME_ID, referencedColumnName = COLUMN_NAME_ID, nullable = false, updatable = true),
@JoinColumn(name = "COLUMN_NAME_VERSION", referencedColumnName = COLUMN_NAME_VERSION, nullable = false, updatable = true) })
private Set<SettingPdo> settings;
}
Now, the setting looks like this:
@Embeddable
@Table(
name = "settings",
uniqueConstraints = @UniqueConstraint(
columnNames = { "id", "version", "key", "type" }))
public class SettingPdo implements Comparable<SettingPdo> {
@Column(name = "type", nullable = false)
private String type;
@Column(name = "key", nullable = false)
private String key;
@Column(name = "value", columnDefinition = "CLOB NOT NULL", )
@Lob
@Convert(converter = JsonNodeStringConverter.class)
private String value;
}
Now, from time to time if I replace an instancePDO with a Merge operation, a delete statement is generated like this:
Error Code: 932
Call: DELETE FROM settings WHERE ((((((key = ?)) AND (type = ?)) AND (value = ?)) AND (id = ?)) AND (version = ?))
bind => [4 parameters bound]
Now, the problem is that Oracle does not accept a WHERE clause on a CLOB (or any other LOB) column. I drained all stack overflow reading all similar threads like this: https://stackoverflow.com/a/33833399/1549977
If you use a Set and make the element Column be not null, then hibernate will make a primary key with the join column and element column.
As you can see, Eclipselink will still generate delete statements which contains comparisons on a CLOB field.
Hashcode an equals are also correct.
I have no idea what to do next. What's wrong with my classes (or database, for that matter)? As I am stuck with Oracle, how can I force JPA not to include some specific columns in a delete statement?
Thanks in advance!