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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:49:15+00:00 2026-06-05T07:49:15+00:00

I have an user and a privileg class. The user can have many privileges.

  • 0

I have an user and a privileg class. The user can have many privileges. So far so good.

I have some similiar of these relation to the user class. But i don’t want to clutter the user with all these stuff.

So i thought it would be a good idea to make the relation between user and privileg explicit.
I would like to get a class UserPrivilges with a one-to-one relation to user and a one-to-many relation to privileges.

Would be nice to get some feedback if this is possible.

Thx
Per

  • 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-06-05T07:49:16+00:00Added an answer on June 5, 2026 at 7:49 am

    If I understand correctly, you just want to group several OneToMany associations inside a separate class, and have an instance of this class inside User. But semantically, these associations are associations between the User and other entities.

    If so, you should keep your database scheam as is, and simply use an embedded object inside User to group your associations:

    @Embeddable
    public class UserPrivileges
        @OneToMany
        private Set<Privilege> somePrivileges;
    
        @OneToMany
        private Set<Privilege> someOtherPrivileges;
    
        @OneToMany
        private Set<Privilege> yetOtherPrivileges;
    }
    
    @Entity
    public class User {
    
        @Embedded
        private UserPrivileges privileges;
    }
    

    See the documentation for more details.

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

Sidebar

Related Questions

show databases shows all databases where you (logged in user) have some privileges. Is
I have user (not administrator) access to some external JMS. I'm failing to view
I have some code, with which I'm trying to get the current session user
I have some answers! Feel free to contribute your own findings. As far as
Here is roughly what I have: I have many companies that has many user
I am using the sql developer and so far I have a schema class
I have seen so far a Twig method to know the user privilege {%
I have a requirement to implement user privilege elevation in an MVC3 web app,
I have user control in my MVC2 app placed in the Content folder (it's
I have user generated podcasts, each with their own RSS feed. Is there a

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.