cgamble wrote:
I am writing an application that works with Inventory. After adding the set as defined below, hibernate throws an initialization exception. I am using hibernate 3.0.3 on postgresql 8, though my real problem i fear lies in the fact that I just dont seem to be able to understand collections in hibernate.
JAVA and Xml included below
table design
Table Parts
part_id [ Primary Key ]
Table Assembly_Parts
Assembly_Part_Id [ Primary Key ]
Kit_id [ Link to Parts table ]
Part_id [ Link to Parts table ]
Qty_Of_Part [ float ]
java classes
Part.java
int id = 0;
Set assembly_parts = new HashSet();
AssemblyPart.java
Part kit_id = new Part();
Part part_id = new Part();
float qty_of_part = 0;
In my Part XML, I am trying to create a set of assembly parts using a set as follows [ the comments are not in the real xml file ]
<class name="Part">
<set name="assembly_parts"> // i think this is supposed to be the name of the collection on the parent?
<key column="kit_id" /> // From best I can understand, the key refers to the kit_id field in the Assembly_Parts table
<one-to-many class="AssemblyPart" />
</set>
</class>
After adding this to my hibernate.hbm.xml file, It will no longer work. I have narrowed it down to the <set> tag, because the entire application works perfectly if I remove it. Can someone point out where I am blantantly wrong on the design of this file?
I can provide more if needed, but as i believe the problem is completely my comprehension, hopefully this will be enough.
Thanks,
Should be <key column="part_id"> since this is what tells Hibernate the how the AssemblyPart is related to the Part.
I would need to see your code and the stack trace to provide any meaningful information beyond this.