With all my little knowledge with hibernate, I am trying to work on a relationship between CATEGORY and ITEMS. Its a simple one to many relationship but when i try to add an ITEM it also adds the category again for that item. That should not be the case; Category is just a select list in the Gui.
My poor mappings are as follow;
I know this is something very tiny but cant find, So Please F1 F1 F1
Also, do you have interfaces for your domain objects? Usually you don't.
Are you setting both sides of the relationship. Meaning are you adding the Item to the collection in Category, and are you setting the Item's Category, and htat Category that you are adding being the one that has the id set. If you are adding a Category that doesn't have an id, then it will do an insert on that Category object.
Yes I do have the bi-directional relationship, I mean Category has Set of Items and Item has Category object. When I am adding item, I expect to take the Category id from the Gui(selectList) that is populated from Categories in DB. I dont want it to add new category.
So, I might have done some wrong relationship or concept. Classes are as follow;
About Interfaces for the Domain Objects I had them before but not now, just did not changed the names. By the way Which classes should have and not have interfaces ?