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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:39:51+00:00 2026-05-24T22:39:51+00:00

I have 2 classes with @ManyToMany relationship first class: Clip second class: Location the

  • 0

I have 2 classes with @ManyToMany relationship

first class: Clip
second class: Location

the main idea is that a clip can be available in several locations

this is the clip class.

@Entity
@Table(name = "CLIP")
public class Clip {

    private Long id;
    private List<Location> locations;

    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }

    @ManyToMany( )
           @JoinTable(name="CLIP_LOCATION",joinColumns=@JoinColumn(name="CLIP_ID",nullable=false),inverseJoinColumns=@JoinColumn(name="LOCATION_ID",nullable=false) )
    @ForeignKey(name="FK_CLIP_LOCATION",inverseName="FK_LOCATION_CLIP")
    public List<Location> getLocations() {
        return locations;
    }
    public void setLocations(List<Location> locations) {
        this.locations = locations;
}
}

this is the Location class

@Entity
@Table(name = "LOCATION")
public class Location {
}

this is not a bi-directional relationship

My Question:
When i remove a location from the user interface , i want the relevant row in the join-table to be removed automatically,

Can i do that?

what annotation should i use?

Note that the Location class and Clip class are used in other relationships too

Thanks
Maayan
Am i using the wrong relationship?

  • 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-24T22:39:52+00:00Added an answer on May 24, 2026 at 10:39 pm

    This is not possible. You have to remove the location from the lists of locations before deleting the location. Since your association is unidirectional, you’ll have to execute a query to find all the clips available on the location, and remove the location from each clip.

    Another option is to execute a native SQL query to remove rows from the join table, but keep in mind that the entities aready loaded in the session won’t be aware of the change.

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

Sidebar

Related Questions

I have a ManyToMany relationship between two classes, for instance class Customer and class
I have two classes with a ManyToMany relationship. I'd like to select one from
I have classes A1, A2, A3, A4 derived from a class A. How can
I have classes that are structured like the following: public class Forecast { [Key]
I have this 2 classes: @Entity public class Student extends User { ... @ManyToMany(mappedBy
I have classes that store data, and methods to go get data for individual
I have classes that are named exactly the same across different plug-ins that I
I have classes that are needed in both my web service and my server.
If I have classes of Type A and B: public class A { public
I have some classes layed out like this class A { public virtual void

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.