I succesfully used the code described in the forum to create a custom UserType for the Oracle XMLType column. However this code seems to only work for data less than 4000.
I did some single stepping and found that net.sf.sql.Insert is used to generate the prepared statement for the SQL INSERT. The issue with the XMLTYPE is that the prepared statement must use xmltype(?) not '?'.
Code from net.sf.sql.Insert
Code:
public Insert addColumn(String columnName) {
return addColumn(columnName, "?");
}
Code:
<hibernate-mapping>
<class name="com.xerox.isrve.parm.bus.ReportRequest" table="REQPARM" dynamic-insert="true">
<id name="id" type="long" column="REQUEST_ID">
<generator class="sequence">
<param name="sequence">GUIPARMS.REQ_SEQ</param>
</generator>
</id>
<property name="reportId" column="REPORT_ID"/>
<property name="xmlText" type="com.xerox.isrve.tools.util.HibernateXmlType" column="PARAMETERS"/>
<property name="parentId" column="PARENT_REQUEST_ID"/>
<property name="savedRequestFlag" column="SAVED_REQUEST_FLAG"/>
<property name="savedRequestName" column="SAVED_REQUEST_NAME"/>
<property name="scheduleId" column="SCHEDULE_ID"/>
<property name="status" column="STATUS"/>
<property name="createDate" column="CREATE_DATE"/>
<property name="createdBy" column="CREATED_BY"/>
</class>
</hibernate-mapping>
In my example the PARAMTERS column is an XMLTYPE. Hibernate generates the following prepared statement:
insert into REQPARM (REPORT_ID,
PARAMETERS, SAVED_REQUEST_FLAG, STATUS, CREATE_DATE, CREATED_BY, REQUEST_ID) values (?,
?, ?, ?, ?, ?, ?)
The statement must be:
insert into REQPARM (REPORT_ID, PARAMETERS, SAVED_REQUEST_FLAG, STATUS, CREATE_DATE, CREATED_BY, REQUEST_ID) values (?,
xmltype(?), ?, ?, ?, ?, ?)
My question is how can I configure hibernate to change the default prepared statement placeholder?
Thanks.