-
May 14th, 2007, 04:40 AM
#1
Delete using a composite-key (Spring/ Hibernate)
Hello,
This is a so simple operation, but I think I am little lost with some concepts.
Let's say that I have product and item and I want to delete an item like:
public void delete (Product productParam, int codeParam) {
Item it = new Item();
it.setCompositeKey(productParam);
it.setCodeX(codeParam);
}
this.getHibernatTemplate().delete(it);
Map for Item
------------
...
<many-to-one name=item class=Item> <!-- Composite key -->
<column name="code1">
<column name="code2">
</many-to-one>
I would like to do that on the programatic way instead of using the map.
Using this implementation the code1 and code 2 are null when send through the delete, even though it has value when received from the parameter.
Could you give me some clues please?
-
May 14th, 2007, 06:40 AM
#2
I have to confess I haven't tried to do this before. Usually you have the item you want to delete, query for it and then delete it or issue a bulk update statement to do it for you.
-
May 14th, 2007, 08:33 AM
#3
Hello karl, thanks for your answer. Would mind to provided me with some reference and/ or examples about what you have said?
Also, how do you have handled with this kind of situation?
Actually, there is a little correction in the map. Instead of Item it's Product
Map for Item
------------
...
<many-to-one name=product class=Product> <!-- Composite key -->
<column name="code1">
<column name="code2">
</many-to-one>
Thanks.
-
May 14th, 2007, 10:31 AM
#4
Urgent please
Please, if anyone has this answer let me know as soon as you can. Thanks.
-
May 14th, 2007, 11:23 AM
#5
-
May 14th, 2007, 12:05 PM
#6
Thank you so much Karl. I will let you know the outcomes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules