Closed nscuro closed 4 months ago
Just learned about the insert-function
and update-function
extensions, which make the tests pass:
@Persistent
@Column(name = "DATA", jdbcType = "CLOB")
@Extensions({
@Extension(vendorName = "datanucleus", key = "insert-function", value = "(?::JSONB)"),
@Extension(vendorName = "datanucleus", key = "update-function", value = "(?::JSONB)")
})
private String data;
I think this is sufficient.
Feature Request
PostgreSQL has dedicated types for JSON:
JSON
andJSONB
.To clients, both behave pretty much like
TEXT
.At the moment, DataNucleus can correctly fetch
JSON
andJSONB
values asString
, but it cannot persist them. I published test cases here: https://github.com/nscuro/datanucleus-test-jdo/blob/postgres-json-jsonb/src/test/java/org/datanucleus/test/SimpleTest.javaTo summarize the tests: Trying to persist an object with
JSON
orJSONB
columns currently yields the following exception:In raw SQL, this would be addressed by type casting, i.e.:
In JDBC, the same can be achieved with:
I'd be happy to contribute a PR for this, but I'd very much appreciate a nudge as to what would need to be done.