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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:43:21+00:00 2026-05-29T21:43:21+00:00

My basic scenario is a bi-directional many-to-many relationship that is being mapped with JPA.

  • 0

My basic scenario is a bi-directional many-to-many relationship that is being mapped with JPA. Simple enough. However, I need to add a ‘type’ to the mapping, and I’m struggling with the best implementation. Here’s the outline:

Network
   Set<Member> defaultMembers; //members that meet the network definition
   Set<Member> suppressedMembers; //members that meet the network definition, but are hidden.
   Set<Member> addedMembers; //memders that don't meet the network definition, but have been added in anyway.

Member
   Set<Network> attachedNetworks;

If I didn’t need this to be bi-directional (e.g., I only needed to get to members from networks and didn’t need to be able to travel the other way), the most obvious solution to me is one link table for each set of members (network_member, suppressed_member, added_member), but that falls apart going the other way. I suppose I could use a single link table and turn it into an entity with a discriminator column, but every time I’ve seen someone use a link table as an entity the code seems to turn into a disaster.

I’ve found many similar questions, but the questions have either been a little too specific, or the answers haven’t quite covered the solution I’m seeking. Any suggestions on the best way to handle this situation?

  • 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-29T21:43:24+00:00Added an answer on May 29, 2026 at 9:43 pm

    The obvious, portable solutions are the following ones:

    1. use three join tables, and also have 3 sets of networks in the Member entity
    2. use an additional Attachment entity, having a member, a network, and a type of attachment (default, suppressed or added). Have a OneToMany bidirectional association between Network and Attachment, and another OneToMany bidirectional associatio between Member and Attachment.

    If they don’t fit, please explain why.

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

Sidebar

Related Questions

Basic question here - I have many lines of code that look something like:
This is a pretty basic scenario but I'm not finding too many helpful resources.
Scenario A image website that has basic features such as upload, comment, like, follow
Ok - pretty basic scenario, been there before, seemed all so simple - but
I've got a relatively basic scenario where I've got a nav HTML element that
I have a very basic question. Scenario: 2 forms Form1, Form2- Dialog box which
Hi I have code which sets up a basic client to server scenario and
I'm looking for a basic search functionality with JavaScript. The Scenario : The user
I have to generate winword document for badges printing application. Basic scenario is the
My basic problem is that I want to use some structs and functions defined

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.