Hi,
I have a problem using hibernate with the postgres sql specific column type xml.
Code:
@Column(columnDefinition="XML", name="document", nullable=false)//columnDefinition="LONGTEXT"
private String xml = null;
public String getXml() {
return xml;
}
public void setXml(String xml) throws ConfigurationException {
this.xml = xml;
this.xmlDocument = XMLUtils.stringToXml(xml);
}
The generation of the database scheme works fine, but i get an exception caused by postgres when trying to insert my object as follows:
Code:
org.postgresql.util.PSQLException: ERROR: column "document" is of type xml but expression is of type character varying
OK - i know what this exception means and that postgres exspects an XML type as defined but i am trying to commit an varchar (String).
I have tried to use w3c.document instead but as exspected hibernate isn't able to map this.
So - does anybody know what kind of datatype to use in my classes that i am able to store something to a xml column in postgres ?
I know that postgres supports some String to XML mapping that will generate the right type, but is there a way to execute custom SQL while hibernate doing all his inserts ?
Hope that anybody can help
Cheers, Tobias