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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:15:50+00:00 2026-05-16T02:15:50+00:00

Customer Entity (Parent Entity) @Entity public class Customer { @Id @GeneratedValue(strategy = GenerationType.AUTO) private

  • 0

Customer Entity (Parent Entity)

@Entity
public class Customer {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private String name;

@OneToMany(mappedBy="customer", cascade=CascadeType.ALL)
private List<Facility> facilities;

//Setter and Getter for name and facilities

public void addFacility(Facility facility){
    if(this.facilities == null){
        this.facilities = new ArrayList<Facility>();
    }
    this.facilities.add(facility);
    facility.setCustomer(this);
}
}

Facility Entity (Child Entity)

@Entity
public class Facility {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne
@JoinColumn(name="CUSTOMER_FK")
private Customer customer;

private String name;

//Setter and Getter, equals and hashcode
...
}

in Customer entity, I use CascadeType.ALL, however when I remove a customer, the associated facilities are still there. I delete customer by

Query query = em.createNamedQuery("Customer.delete");
query.setParameter("id", customerId);
query.executeUpdate();

where

@NamedQuery(name="Customer.delete", query="delete from Customer c where c.id = :id")
  • 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-16T02:15:51+00:00Added an answer on May 16, 2026 at 2:15 am

    Bulk delete operations are not cascaded, per JPA specification:

    4.10 Bulk Update and Delete Operations

    …

    A delete operation only applies to
    entities of the specified class and
    its subclasses. It does not cascade to
    related entities.

    …

    If you want to benefit from cascading, load the entity and then call EntityManager#remove(Object) on it.

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

Sidebar

Related Questions

I got two Entity: Customer Entity @Entity public class Customer { @Id @GeneratedValue(strategy =
I got a Entity with a Integer @Entity(name=customer) public Customer { ... @Column private
This is an extract of the JPA entities schema @Entity @Table(name=customer) public class Customer
I have a Customer class defined like this: @Entity public class Customer { //...
Suppose i have a classes like this @Entity public class Customer implements Serializable {
I have following entity class User: public class User implements Serializable { @Column(length =
I have a base class called Entity: public class Entity { public int Id
I want to create a one to one mapping between the Entity Customer and
In this example, the Google App Engine documentation makes the Customer the entity group
I am new to CRM development. I have a Custom Entity customer. This Entity

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.