Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Using Struts2 to xml format Hibernate objects

Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi all,

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?

Everybody! Do the Funky Monkey! Like this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic