QueryDSL/Talend JDBC with Postgresql xml type : XML altered on SQL insert or update (arithmetic computations)



Hi everybody,


I'm stuck with an issue especially annoying. It lie on the insert or update of an xml content into an Postgresql xml type field via JDBC.


Context


Below, the structure of the table:



CREATE TABLE articles (
article_id integer NOT NULL,
article_xml xml NOT NULL
);


I use the QueryDSL library to build the SQL queries in the applications, but the initial data came from a OpenLink Virtuoso server, that have been migrated with Talend, so JDBC based transactions also.


A sample XML would be:



<?xml version="1.0" encoding="UTF-8" ?>
<ArticleSimple>
<id>22754</id>
<departement>64 / 56</departement>
</ArticleSimple>


A sample update query would be:



update "Shared"."articles"
set "article_xml" = xml '[xml value]',
where "articles"."article_id" = 22754


I also tried others synthaxes for the XML value, with no success (for my issue):



no expression at all just the xml value
XMLPARSE (DOCUMENT '[xml value]')
XMLPARSE (CONTENT '[xml value]')
'[xml value]'::xml


Also, all of those synthaxes works in phpPgAdmin or PgAdmin.


In java a sample QueryDSL UpdateClause:



SQLUpdateClause clause = buildUpdate(connection, articles)
.where(articles.articleId.eq(articleID))
.set(articles.articleXml, xml([xml value]));


in which "xml" function is define as such:



protected static StringExpression xml(String xml)
{
return StringTemplate.create("xml {0}", xml);
}


The JDBC driver version i use is: postgresql-9.1-903.jdbc4


The issue


First and foremost, no problems happens when i execute a query directly in phpPgAdmin or PgAdmin, since, the problem must appear in an other layer, probably JDBC.


At some point, the xml is altered and transformed to a such output, based on the provided sample:



<?xml version="1.0" encoding="UTF-8" ?>
<ArticleSimple>
<id>22754</id>
<departement>1,142857142857143</departement>
</ArticleSimple>


You can see that "departement" tag content has been computed as if it was an arithmetic expression, which is weird and not what i want to.


For the Talend migration job, i have no output that i can print out, so i can just say that the problem appears also in the migrated data, and that the synthax for the xml value used in the job for the insert statement is :



XMLPARSE (DOCUMENT '[xml value]').


For QueryDSL, i can say that before the SQLUpdateClause construction the xml input is not altered, after that when i print the SQL for the SQLUpdateClause, the xml value is altered:



update "Shared"."articles"
set "article_xml" = xml '<ArticleSimple><id>22754</id><departement>1,142857142857143</departement></ArticleSimple>'
where "articles"."article_id" = 22754


Question


I'm wondering if anybody have already met a similar issue and found a turnaround, or if anyone have any clue ?


Thanks in advance to those who will read my post, and suggest any track or solution !


No comments:

Post a Comment