I'd like to add a few more details about the code changes made to 1.2.x and 2.0.x. These details are in addition to the previous (and vitally important) details added by Jeremy. In addition to his requirements, it should be noted that the code changes made in this JIRA are gated (enabled/disabled) via a system property. The system property is named 'supportsSetClob' and is defined on the Oracle dictionary class. As an example, the property can be defined as follows:
<property name="openjpa.jdbc.DBDictionary" value="oracle(supportsSetClob=true)"/>
Next, it should be noted that we expect the XML field(s) to be annotated with:
This allows a user to indicate that OpenJPA should use JAXB classmetadata to perform the to/from database value retrieval and storage. In addition, using this strategy indicates there is an XMLType used to store the value in the database. Instead, we've seen customers attempt to managing their own XML string, mapped to a string field, and expect the code changes of this JIRA to apply. While a user has an XMLType specified in the column definition, OpenJPA cannot count on this data to detect whether the column is really an XML column in the database (the table could have been created manually with separate DDL instead of using OpenJPA's mapping tool).
In this case, where the user is doing their own String mapping rather than using the XMLValueHandler, there are some additional settings a user may need to set/enable in order to resolve the issue addressed in this JIRA. The necessary settings/actions are as follows:
First, it may be necessary to annotate an XML field with @Lob, as follows:
@Column(name="CONTENTS_XML", columnDefinition ="XMLCOLUMN XMLType")
private String contentsXml;
Second, in addition to annotating the XML field with @Lob, a user may also need to set this dictionary property:
Therefore, the final DBDictionary property would be:
<property name="openjpa.jdbc.DBDictionary" value="oracle(supportsSetClob=true,maxEmbeddedClobSize=-1)"/>
Finally, a user may need to use the native schema factory to pick up the XMLType from the database, that property is as follows:
<property name="openjpa.jdbc.SchemaFactory" value="native"/>
By enabling OpenJPA's native schema factory, the database column type can be detected as XMLType.