• Post Reply 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How could I map this if possible?

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am rather new to Hibernate and am trying to persist and load an class with an encapsulated map. It does not work and I guess I am doing something wrong in the mapping of the two involved classes. But I think it should be easy and it would be great if someone who knows could show me how it should be mapped to save me all the time to find it out myself using trial and error.

I have two classes something like these:



When I do a session.save(aContainerObject) do I want the Container object to be saved together with all the ContObjects contained in the map with correct foreign key revision set to the id of the newly saved Container object. May that be possible and if so, how should then the two .hbm.xml-files look like? Particularly, I use the workOrder (from column orderstring) as map key but it does not work as a primary key because it may not be unique. Here is one of my tries so far ...

Container.hbm.xml



ContObject.hbm.xml



In the database do I have the columns id and create_time for a Container record and values for both columns is automatically generated in an insert which works fine. The table ContObject has the columns id, revision, orderstring and otherString. The id is an auto increment and the revision is a foreign key to a Container record through the id of that record.
 
For my next trick, I'll need the help of a tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic