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 524669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:35:31+00:00 2026-05-13T08:35:31+00:00

The goal is to remove all Dependent when their Owner is deleted. I have

  • 0

The goal is to remove all Dependent when their Owner is deleted. I have the following classes:

@Entity
class Dependent {    
    @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY, optional = false)
    @Column(name = "OWNER")
    private Owner _owner;
}

@Entity
class Owner {
...
}

In the current implementation Dependent still exist after its Owner has been deleted.

Owner doesn’t have any links to Dependent and can’t be changed, so I can’t use @Dependent annotation or cascade=DELETE.

Does JPA support such “inverse dependency”?
Another question is what does optional=”false” guarantee while the field _owner is being deleted?

  • 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-13T08:35:32+00:00Added an answer on May 13, 2026 at 8:35 am

    You have two options: You must either add a bag/set/list to the class Owner with cascade-delete. You can make this bag lazy and never access it, so it won’t have a performance impact until you delete.

    Your other option is to delete the Dependent instances with a query when you delete the owner. Since JPA doesn’t do automatic garbage collection of instances, you must start the delete manually anyway, so just make sure that every uses a single function to delete owners and then add the call to delete the children there.

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

Sidebar

Related Questions

My goal is to remove all <[script]> nodes from a document fragment (leaving the
I have a form that, for example, allows people to enter all their siblings.
My goal is to remove all hover feedback from the UI. The motivation is
This is the goal: to remove Navigation Bar in some of the editors (no
My goal is to remove IE conditional comments from my documents' <head> , but
Given the following XAML my goal is to keep the columns AAA, BBB, CCC
(First of all, sorry for my english, it's not my first language) I have
I want to remove all strange characters from a string to make it url
So, I've got a massive XML file and I want to remove all CDATA
I have the following Python 2.7 dictionary data structure (I do not control source

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.