views:

46

answers:

2

Hi,

I would like to know if we call a Java class annotated with hibernate classes. Can we get the data from the table in a XML format?

browser give data for id =1 --> Servlet --> hibernate class (with some magic xml functionality) --> returns the data in XML format(Can this really happen?)

Thanks, Sana.

+1  A: 

I am not sure if you can do this directly with Hibernate, but you could use a 3rd party library like XStream to transform the object you have stored your results in to XML.

Sean
+1  A: 

I don't have any particular experience with this feature but Hibernate allows you to work with persistent XML that you can persist to or read from the database. See Chapter 18. XML Mapping. I'm not sure it's still actively developed though, and it doesn't support annotations AFAIK.

As an alternative, you could use Hibernate/JPA + JAXB (in which case, I'd suggest to check HyperJAXB).

Pascal Thivent
Thanks a lot, it worked. I will post the code snippet soon.
Sana