One of the columns is of type XMLTYPE in an Oracle database. In my application, I want to save data and use Hibernate.
I did the following to display XMLTYPE in hibernate
I am facing a problem when creating an XMLType in a custom type
XMLType.createXML(st.getConnection(),HibernateXMLType.domToString((Document) value));
where st is the prepared state passed to the method.
The connection object returned by st.getConnection () is of type org.apache.commons.dbcp.PoolableConnection
But the createXML method only expects a connection object of type oracle.jdbc.OracleConnection
I also tried to get getInnermostDelegate, but this also does not work.
Ways to create XMLTYPE are in the included jar xdb.jar - will there be any changes depending on the version?
thank
++++++++++++++++++++++++++++++++++++++++++++++++++ +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++ ++++
Got an SQLConnection object using the code below -
SimpleNativeJdbcExtractor extractor = new SimpleNativeJdbcExtractor();
PoolableConnection poolableConnection = (PoolableConnection) extractor
.getNativeConnection(st.getConnection());
Connection sqlConnection = poolableConnection.getInnermostDelegate();
Now java.sql.SQLException error message : Invalid column type
Below method
public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {
SimpleNativeJdbcExtractor extractor = new SimpleNativeJdbcExtractor();
PoolableConnection poolableConnection = (PoolableConnection) extractor
.getNativeConnection(st.getConnection());
Connection sqlConnection = poolableConnection.getInnermostDelegate();
try {
XMLType xmlType = null;
if (value != null) {
xmlType.createXML(sqlConnection, HibernateXMLType
.domToString((Document) value));
}
st.setObject(index, xmlType);
} catch (Exception e) {
e.printStackTrace();
throw new SQLException(
"Could not convert Document to String for storage");
}
}
Left without a clue ...