ConversionException for SQL data type XML

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ConversionException for SQL data type XML

Lars-Fredrik Smedberg
Hi!

We are using IBM Webspher Liberty Profile that bundles EclipseLink 2.6.5 (according to the stacktrace...).

We are trying to get the SQL data type XML working according to how we think it should work...

According to e.g. 


the XML data type maps to the following recommended Java type java.sql.SQLXML for update and retrieval. This type however
is not a type supported by JPA (to my understanding since it is not amongst the supported basic types and the interface does 
not mark it as Serializable). 

Amongst the other supported Java types for update and retrieval we find java.lang.String and byte[].

We have successfully used java.lang.String to insert and select data using an entity with a property mapping to a table column of type XML.

However when trying to use byte[] we can insert without an error but when we try to select we get the following ConversionException (slightly stripped from the full document we try to select)....

Any ideas?

Best regards
LF



Caused by: Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.6.5.WAS-v20180104-90e991c): org.eclipse.persistence.exceptions.ConversionException 
Exception Description: The object [<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence              http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1"><persistence-unit name="jaft" transaction-type="JTA"><provider>shb.rinf.persistence.ManagedPersistenceProvider</provider><jta-data-source>jdbc/acp01</jta-data-source><mapping-file>META-INF/jaft_orm.xml</mapping-file><jar-file>lib/jaft-enterprise-${jaft-version}.jar</jar-file><!-- 
                    Turn off 2:nd level cache, L2 
                    Since JPA 2.0 there is a persistence-unit property 'shared-cache-mode' that is better 
                    to use than the eclipselink specific 'eclipselink.cache.shared.default' 
                    L2 cache is by defalt on and this does not work in a clustered 
                    environment without configuration for cache coordination. 
                    Supports JMS, RMI, JGroups. 
            --><shared-cache-mode>NONE</shared-cache-mode><properties><!--  --><property name="eclipselink.jdbc.batch-writing" value="JDBC"/><!--<property name="eclipselink.jdbc.batch-writing.size" value="100"/> default--><!-- EclipseLink logging for test --><property name="eclipselink.logging.level" value="ALL"/><property name="eclipselink.logging.parameters" value="true"/><!-- EclipseLink target db set to db2 on zOS, see http://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_tl_ext001.htm 
            <property name="eclipselink.target-database" value="DB2Mainframe"/> 
            --><property name="eclipselink.target-database" value="DB2"/></properties></persistence-unit></persistence>], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[xml-->laos01.XML00.XML_DATA]] with descriptor [RelationalDescriptor(shb.jaft.xml.v1.entity.XmlByteEntity --> [DatabaseTable(laos01.XML00)])], could not be converted to [class [B]. 
        at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:78) 
        at org.eclipse.persistence.internal.helper.Helper.buildBytesFromHexString(Helper.java:268) 
        at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToByteArray(ConversionManager.java:326) 
        at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:138) 
        at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:198) 
        at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getObjectValue(AbstractDirectMapping.java:622) 
        at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.valueFromRow(AbstractDirectMapping.java:1220) 
        at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.buildCloneFromRow(AbstractDirectMapping.java:205) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:1999) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:2252) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:850) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:737) 
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:691) 
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:805) 
        at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:962) 
        at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:573) 
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1175) 
        at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:911) 
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134) 
        at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:460) 
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222) 
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2899) 
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1863 ) 
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1845) 
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1810) 
        at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258) 
        at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:473) 
        ... 79 more 


--
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at [hidden email], and destroy all copies of this
message and any attachments.

_______________________________________________
eclipselink-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users