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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:31:15+00:00 2026-06-12T04:31:15+00:00

First CascadeType.Remove is not an option because the client side database may not support

  • 0

First CascadeType.Remove is not an option because the client side database may not support cascade operation.

I guess OrphanRemoval = true only handle @OneToXXX relationships.

How about many-to-one relationships?

For example a many-to-one mapping like this:

public class Order{
    ....
    @ManyToOne
    private Customer customer;
    .....
}

In Customer entity there is no mapping to Order which make the relationship become one-direction.

Then how can we remove all orders from a customer before removing that customer? Is there a simple automatic way to handle that or we have to implement the code explicitly via service layer and call something like findOrdersByCustomer(long customer_id) then remove them?

Thanks in advance.

  • 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-06-12T04:31:16+00:00Added an answer on June 12, 2026 at 4:31 am

    Yes, you’ll need to find all the orders and remove them. Or you can also execute a JPQL query deleting everything:

    delete from Order o where o.customer = :customer
    

    Note that your note about CascadeType.REMOVE is wrong: it’s JPA that executes the cascade, and not the database. It’s thus supported whatever the database is.

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

Sidebar

Related Questions

i have relationship: // In A.java class @OneToMany(mappedBy=a, fetch=FetchType.LAZY) @Cascade(CascadeType.SAVE_UPDATE) private List<B> bList; //
First of all I want to say I am not a programmer but I
First of all, this isn't for a keylogger, it's for an input in a
first take a look on this picture from localScope app : i have 2
first of all some details: I configured security as below in web.xml view plaincopy
first off I'm a noob to PHP but here is my problem. I am
First off, I'm coming (back) to Java from C#, so apologies if my terminology
First, some context: I'm a Python developer who has written a medium-sized application using
First i selected images from photo library to ALAsset Library and after that i
First you should know I have looked into many questions and none of them

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.