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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:04:50+00:00 2026-05-24T07:04:50+00:00

I have two persistent classes. They are are in many-to-many relationship. One class have

  • 0

I have two persistent classes. They are are in many-to-many relationship. One class have a set of objects of another class.
@Entity class A {
@Id @Generated int id;
@ManyToMany(cascade = CascadeType.ALL)
Set<B> myset = new HashSet<B>();
}

and

@Entity class B {
@Id @Generated int id;
}

Hibernate makes table: A_B with columns A_id and B_id. If i delete some A or B object, any entrie in A_B table makes no sense anymore. Can it be deleted automaticly?

  • 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-24T07:04:51+00:00Added an answer on May 24, 2026 at 7:04 am

    When you delete A, you should clear its set of Bs before.

    When you delete B, you should remove it from the set of Bs of every A. This os of course easier if you make the relationship bidirectional.

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

Sidebar

Related Questions

I have two classes. One is Order: public class Order { public virtual int
I have two classes in an owned one-to-many relationship. The parent is Map, and
I have defined a many-to-many relationship between my two entity classes User and Permission.
I have a persistent class Author with two fields: int id , String name
I have two classes, and want to include a static instance of one class
i have two tables mapped by JPA with One to Many relationship. I want
I've got two classes (Students and Courses) which have a many-to-many-relationship. Instances of them
I'd like to have a combined query for two persistent classes. In HQL this
I have three classes (House, Room, Address) which are persistent (Mapped with JPA/Hibernate) @Entity
I have two classes: public class Parent { public virtual long? ID { get;

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.