I am new to JPA, and I have a question on how to use JPA to store XML type to PostgreSQL. I am simply expanding an existing POJO to include persisting an additional XML field to a column. The POJO looks something like this (I purposely left out a bunch of other columns to make this shorter, before adding this additional XML type, this POJO can persist into PostgreSQL just fine via JPA).
public class Finding implements Serializable {
private static final long serialVersionUID = -5814053129578212916L;
...
@Column(name = "PLUGIN_TEXT_XML")
private String pluginTextXML;
public void setPluginText(String pluginText) {
this.pluginText = pluginText;
}
public String getPluginTextXML() {
return pluginTextXML;
}
}
When I try to persist this POJO, I received a PSQLException
Caused by: org.postgresql.util.PSQLException: ERROR: column "plugin_text_xml" is of type xml but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 668
I have been trying to look online on how to map a XML type in JPA but no luck. If anyone can give me a hand or point me to a site online so I can read up more on it then it would be a great help! Thank you for reading!