Inserting Postgres' json column using wildfly Inserting Postgres' json column using wildfly json json

Inserting Postgres' json column using wildfly


Adding org.postgres dependency to the war manifest solved the issue for me.

Here is a maven snippet:

<build>    <plugins>        <plugin>            <artifactId>maven-war-plugin</artifactId>            <configuration>                <archive>                    <manifestEntries>                        <Dependencies>org.postgres</Dependencies>                    </manifestEntries>                </archive>            </configuration>        </plugin>    </plugins></build>

And here is the generated MANIFEST.MF (see the last line):

Manifest-Version: 1.0Archiver-Version: Plexus ArchiverBuilt-By: dedekCreated-By: Apache Maven 3.3.3Build-Jdk: 1.8.0_51Dependencies: org.postgres


So managed to work around this by simply changing the insertion method to now require any postgres jdbc specific method by:

Changing the query to this,

INSERT INTO table (json_column) VALUES (to_json(?::json))

And changing the method in the prepared statement to this:

 preparedStatement.setString(1, json);

This solved the issue for me, not sure if it's the best/most eficient solution but it works.