Versions:
--Hibernate 3.2.5
--PostgreSQL 8.3
I've created a UserType to map the XML data (saved as Type XML) into beans using XMLBeans. This works perfectly fine.
When it comes time to save the data I'm getting conversion errors (char to xml) thrown by PostgreSQL.
I've overridden the nullSafeSet function and have tried multiple things:
1) Using PostgreSQL's functions to convert strings to XML:
Code:
XMLPARSE( DOCUMENT "xml goes here")
2) Tried to use the SQLXML object:
Code:
XmlObject loObject = (XmlObject)value;
Connection conn = statement.getConnection();
SQLXML article = null;
try {
article = conn.createSQLXML();
}catch(SQLFeatureNotSupportedException sfnsE) {
sfnsE.printStackTrace();
throw new HibernateException(sfnsE.getMessage());
}catch(SQLException sqlE) {
sqlE.printStackTrace();
throw new HibernateException(sqlE.getMessage());
}
DOMResult dom = (DOMResult)article.setResult(DOMResult.class);
dom.setNode(loObject.getDomNode()); // doc is instance of org.w3c.dom.Document
statement.setSQLXML(index, article);
Both with no luck.
Has anybody come across this and found a good solution to save PostgreSQL XML Type data?
Thanks.[/code]