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 ...
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.
Truly agile Java application developer with Extreme Programming and high quality craftsmanship