Results 1 to 6 of 6

Thread: Delete using a composite-key (Spring/ Hibernate)

  1. #1

    Default 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?

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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.

  3. #3

    Default

    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.

  4. #4

    Default Urgent please

    Please, if anyone has this answer let me know as soon as you can. Thanks.

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    This is how I tend to do things like this.
    http://www.hibernate.org/hib_docs/v3.../#batch-direct

  6. #6

    Default

    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
  •