This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a project I am working on and, after trying to use Struts2 for it, I have added Hibernate because I thought it would give me an easier way to do what I am trying to do; however, the two are not playing very nicely.
I have a database table, say "Persons," that has a one-to-many relationship with other tables, say "PhoneNumbers" and "Emails" what I am trying to do (and what I thought using Hibernate and Struts2 together would accomplish) is to be able to generate XML over HTTP output in which the entries are nested, something like this:
I am currently trying to use the Struts2 XSLT result type, which works fine using Struts2 but runs into a transform exception using Hibernate (an unhandled exception while trying to use javax.xml.transformer, providing no useful information). The problem is the configuration of the Hibernate classes. Using Hibernate Tools in Eclipse I can automatically generate the POJOS for each table. The variables in the "Persons" class look something like this when generated:
The problem lies with the two Sets that Hibernate Tools creates. If I remove the Sets from my object and also from the mapping files, everything works with no error.
My question then, is there a way to make Struts2 and Hibernate work together to generate XML content? Additionally, is there some easier, better or more preferred way way of producing XML content with the Hibernate persistence layer?