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

  • Home
  • SEARCH
  • 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 871421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:38:18+00:00 2026-05-15T10:38:18+00:00

Ok so this is probably a trivial question but I’m having trouble visualizing and

  • 0

Ok so this is probably a trivial question but I’m having trouble visualizing and understanding the differences and when to use each. I’m also a little unclear as to how concepts like uni-directional and bi-directional mappings affect the one-to-many/many-to-many relationships. I’m using Hibernate right now so any explanation that’s ORM related will be helpful.

As an example let’s say I have the following set-up:

public class Person {
    private Long personId;
    private Set<Skill> skills;
    //Getters and setters
}

public class Skill {
    private Long skillId;
    private String skillName;
    //Getters and setters
}

So in this case what kind of mapping would I have? Answers to this specific example are definitely appreciated but I would also really like an overview of when to use either one-to-many and many-to-many and when to use a join table versus a join column and unidirectional versus bidirectional.

  • 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-15T10:38:19+00:00Added an answer on May 15, 2026 at 10:38 am

    One-to-Many: One Person Has Many Skills, a Skill is not reused between Person(s)

    • Unidirectional: A Person can directly reference Skills via its Set
    • Bidirectional: Each “child” Skill has a single pointer back up to the
      Person (which is not shown in your code)

    Many-to-Many: One Person Has Many Skills, a Skill is reused between Person(s)

    • Unidirectional: A Person can directly reference Skills via its Set
    • Bidirectional: A Skill has a Set of Person(s) which relate to it.

    In a One-To-Many relationship, one object is the “parent” and one is the “child”. The parent controls the existence of the child. In a Many-To-Many, the existence of either type is dependent on something outside the both of them (in the larger application context).

    Your subject matter (domain) should dictate whether or not the relationship is One-To-Many or Many-To-Many — however, I find that making the relationship unidirectional or bidirectional is an engineering decision that trades off memory, processing, performance, etc.

    What can be confusing is that a Many-To-Many Bidirectional relationship does not need to be symmetric! That is, a bunch of People could point to a skill, but the skill need not relate back to just those people. Typically it would, but such symmetry is not a requirement. Take love, for example — it is bi-directional (“I-Love”, “Loves-Me”), but often asymmetric (“I love her, but she doesn’t love me”)!

    All of these are well supported by Hibernate and JPA. Just remember that Hibernate or any other ORM doesn’t give a hoot about maintaining symmetry when managing bi-directional many-to-many relationships…thats all up to the application.

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

Sidebar

Related Questions

This is probably a very trivial question, but I haven't been able to find
Probably for someones this question is trivial but i can't remember which is the
This is probably a silly question, but curiosity has gotten the better of me.
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably a really stupid newbie-sounding question to you developer type people, but
I am only two weeks into WPF so this is probably a trivial question.
Probably this question was already asked before, but my google-fu and SO-Search did not
This is probably quite trivial but.... I have a quite complicated linq query that
this is probably trivial but I need help in making my server listen on
I'm new and this is probably very trivial but I have the following method

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.