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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:50:02+00:00 2026-05-27T15:50:02+00:00

I wonder what the best practice is to deal with a data model like

  • 0

I wonder what the best practice is to deal with a data model like this:
Simple security model

We have 3 entities:

  • Role
  • User
  • Permission

Note that the entities are represented as java classes and will be mapped to a database via hibernate, anyway I think the question could be answered without having knowledge of these technologies.

There is a many-to-many relationship between Role & User and between Role & Permission.

Is it ok to have a bi-directional relationship here? So, that you can ask Role to give you all his members and to ask User to give you all his roles.

It’s very comfortable that you can ask both entities, however one drawback is that whenever you remove a relationship you have to manage both entities.

E.g. if you remove Role from a User you have also to remove the User from the Role. This can be quite annoying if there are many of these relationships. Therefore I would like what the best practice is.

  • 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-27T15:50:03+00:00Added an answer on May 27, 2026 at 3:50 pm

    I try to avoid bidirectional relationships. Instead replace one direction with an explicit query in you DAO/Repository. Keeps the model simpler and if done correctly via interfaces the application clean of circular dependencies

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

Sidebar

Related Questions

I have a dilema and wonder what is business best practice. I'm using Uploadify
I wonder what is the best C# data structure I should use to sort
I wonder that what is the best way of writing a component for joomla
I'm writing a library and wonder what's the best practice for datatypes used in
I wonder what the best practice is for initializing instance variables in a test
I wonder what's the best practice to make a db update thread safe. I
I wonder if there's a best practice when sharing Xcode4 project between multi-developer team.
I wonder, what is the best practice for object validation. Is there any extra
What's the best practice for retrieving JSON values that may not even exist in
I'm working with languages in R​ails, and I wonder what the best practice is

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.