문제

I tried the solutions given online but none of them work. Tools used : Hibernate Maven Eclipse IDE JAXB JSP HTML

I have several bean classes. I have mapped them to the schema as well using hbm xmls.. I am looking to convert the objects to xml and store it in an xml file. Please help me out with an example

도움이 되었습니까?

해결책

I was thinking that rather than loading from the DB on server restart, I could load from the local file!! (as the data in the db updates less often) that's where I got to learn about the XStream Library, and it's so simple that I could convert any java object to XML and back.

Detail

다른 팁

without annotations how do you plan to bind data?

XML is a pure structured language. So, if you are marshaling any object, you need to also tell the structure.

So, if you don't want to put annotations you have to let java know the structure using XSD.

Check this example for using XML Schema Definition.

If you are more interested in finding a simpler solution for marshalling you can try XMLEncoder or if you are comfortable with JAXP, you can pick any one implementation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top