0

We have a requirement where we need to update the XML type column in SQLServer using Hibernate.

Inserting of data is takencare by thirdparty application while we need to update.

To update we retrive a value using API with will provide is DTO which is XML2java Object, we replace couple of values in XML using java object and then update the value using SQL(Here no API provided to update)

When I follow normal SQLQuery and try to update

com.microsoft.sqlserver.jdbc.sqlserverexception XML parsing: line 0, character 0, unrecognized input signature

How to update the value using hibernate 4.x?

rajadilipkolli
  • 3,475
  • 2
  • 26
  • 49
  • Don't know this specific case... Is the XML on SQL Server side the native XML type? Is the XML you are trying to transfer a unicode string? Is the XML coming with a ``-declaration? – Shnugo Jul 10 '17 at 13:16
  • XML on SQL ServerSide is native XML and I am retrieving the value first and then replace one node value with our value and then update it. yes xml is coming with declaration – rajadilipkolli Jul 10 '17 at 13:26
  • Can you post a sample of the XML? It's probably invalid. – David Browne - Microsoft Jul 10 '17 at 14:43
  • If the XML is valid, this might be connected to [this problem](https://stackoverflow.com/a/41505440/5089204). If you pass over an XML with an `encoding="utf-8"` (or other not supported encodings), but SQL-Server treats the input as `NVARCHAR` (which is *unicode / UCS-2*) you get an error. Try to cut away the `` part before you pass this to SQL Server. This declaration is ommited in any case. **SQL Server does not store this declaration!** – Shnugo Jul 10 '17 at 16:58

0 Answers0