Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3341408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:43:09+00:00 2026-05-18T00:43:09+00:00

I have a piece of code that ‘updates’ an entry in the database by

  • 0

I have a piece of code that ‘updates’ an entry in the database by first cascade deleting it, and then replacing it with a new object, because I had a lot of problems trying to update it normally. This hack worked fine, until I started using some ManyToMany relations. This is the relation that is giving problems:

@ManyToMany(cascade = CascadeType.ALL)
private Set<RefProg> refProgSet = new HashSet<RefProg>();

It resides in a domain object called PDBEntry. The RefProg domain object has the following piece of code:

@ManyToMany(mappedBy = "refProgSet")
private Set<PDBEntry> pdbEntrySet = new HashSet<PDBEntry>();

Now as you might have guessed, this goes terribly wrong when you try deleting a PDBEntry. Let’s say PDBEntry “ENT1” has a RefProg “REFPROG1”, and PDBEntry “ENT2” has the same RefProg. Now when I try to cascade delete “ENT1”, it also tries to delete “REFPROG1” which should be impossible, since it is still linked to “ENT2”. But if I don’t set the RefProg to cascade delete, it won’t delete the related rows in the jointable that Hibernate builds for me, giving me an error that it can’t delete the PDBEntry. And since Hibernate is making the jointable it seems I have no access to it. Am I just too stubborn and should I have used an update instead of first trying to delete an entry before entering a new one, or is there some other way to make this work? Maybe is there some annotation to make the cascade get into the jointable and no further? Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:43:10+00:00Added an answer on May 18, 2026 at 12:43 am

    Hav you tried to remove the PDBEntry from the pdbEntrySet and/or vice-versa before making the call to delete the PDBEntry?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of C# code that add the values of an enum
I have a piece of C# code that needs to convert a string array
I have a piece of code here that i really could use some help
Let's say I have to implement a piece of T-SQL code that must return
i have piece of code that works fine on my local test server but
I have a piece of code that involves multiple inserts but need to execute
I have this piece of code that works very well and gives me the
I have a piece of code that looks something like this (ClearImportTable and InsertPage
I have a piece of code that I think should compile, but it doesn't.
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.