How to import XML into SQL Server database?

Hibernate (Java): How to save xml data into database without Entity classes?

  • I want to save XML document values into database. I am using Hibernate 3 with SQL Server Database in my application. There are multiple issue: 1. Firstly I am trying to escape from marshaling XML to Java classes. Reason being that these XML can change frequently. 2. If I have to create Java entities then at least I don't to create respective hbm files. Please help.

  • Answer:

    You can represent your XML as CLOB column in the database. All you need to do is use something like JAXB or XStream to marshal and unmarshal. No need to use HBM files. Simple minimal annotations will do. Just create a POJO that represents the XML. When your XML structure changes, change the POJO. Database doesn't need to know anything about XML, it'll just store long text value (CLOB).

Igor Royzis at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.