Hello,
Similar to HHH-16682, we’re running into an issue where changes to a nested JSON object stored as a JSON string and annotated with @JdbcTypeCode(SqlTypes.JSON)
do not mark the parent entity as dirty when modified. Our existing DB tables store the objects as JSON strings, and we’d like to avoid schema changes.
Our use case is identical to the one described in the issue, except for the fact that our MyJson class is not marked as Embeddable
, e.g. modifying MyJson.stringProp
will not cause MyEntity
to be marked as dirty. It also appears this is deliberate or a known issue based on the description in HHH-16774.
Is there a way for us to take advantage of the built-in JSON type, or some other way to indicate that Hibernate should track the nested entity?
We’re on org.hibernate.orm:hibernate-core
version 6.2.7.Final
for reference
public class MyEntity {
@Id
private Long id;
@JdbcTypeCode(SqlTypes.JSON)
private MyJson jsonProperty;
private String info;
}
public class MyJson {
private String stringProp;
private Long longProp;
}