Hello.
Maybe it’s a bug?
There are two entities:
@Entity
public class Interpretation {
...
@OneToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "uuid", referencedColumnName = "interpretation_uuid", insertable = false, updatable = false),
@JoinColumn(name = "interpretation_version", referencedColumnName = "interpretation_version", insertable = false, updatable = false)
})
public InterpretationData interpretationData;
}
@Entity
public class InterpretationData {
@EmbeddedId
public InterpretationVersion interpretationVersion;
}
@Embeddable
public class InterpretationVersion implements Serializable {
@Column(name = "interpretation_version", nullable = false, updatable = false)
public Long version;
@Column(name = "interpretation_uuid", nullable = false, updatable = false)
public UUID uuid;
}
And when settings have the parametr - hibernate.jdbc.batch_size 1000
then when creating entity Interpretation an error:
InterpretationData interpretationData = new InterpretationData();
...
entityManager.persist(interpretationData);
...
interpretation.interpretationData = interpretationData;
entityManager.persist(interpretation);
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement [Referential integrity constraint violation: "FKAKEPPN0JX5JN1DHRHG8KFINI0: PUBLIC.INTERPRETATIONS FOREIGN KEY(INTERPRETATION_VERSION, UUID) REFERENCES PUBLIC.INTERPRETATION_DATA(INTERPRETATION_VERSION, INTERPRETATION_UUID) (CAST(111 AS BIGINT), UUID 'd76ffb49-2948-4bb0-8320-add1606443b2')";
Apparently for some reason he is trying to first create an Interpretation entity, but should InterpretationData.