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
Related Q & A:
- How to Read xml file in java?Best solution by Stack Overflow
- How to display HTML data from database?Best solution by Stack Overflow
- How to save from DatagridView to Database VB.NET?Best solution by Stack Overflow
- How to listview my data from database SQLite?Best solution by Stack Overflow
- How to write XML file with Java and read it?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.