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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:54:49+00:00 2026-05-23T14:54:49+00:00

I’m trying to persist my data but am having trouble coming up with a

  • 0

I’m trying to persist my data but am having trouble coming up with a schema that will work for hibernate in a sane way

I have two objects: a channel and user. The user is associated with the channel but in many ways. It can have 5 special statuses (and can be assigned multiple ones) or be normal. The issue is complicated by the fact that its a many to many relationship (a user can be in multiple channels and a channel has multiple users).

My idea is to have separate channel and user tables but have a third big map table. This big map table would look something like this

--------------------------------------------------------------------------
| CHANNEL_ID | USER_ID | STATUS1 | STATUS2 | STATUS3 | STATUS4 | STATUS5 |
--------------------------------------------------------------------------
|      5     |    10   |    0    |    1    |    0    |     0   |    0    |
--------------------------------------------------------------------------

Note that if a new user joins a channel, they get a new row. However if they get a new status, their existing row is changed.

Whats really confusing me is how to implement something like that in Hibernate. I’ve got something like this but I’ve been playing around with this so long (2 days now) I don’t even know what it does anymore.

@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "quackbot_user_map", joinColumns = {
    @JoinColumn(name = "USER_ID")}, inverseJoinColumns = {
    @JoinColumn(name = "STATUS1")}) 
protected Set<UserDAOHb> status1s;
  • Is there a better way to do this?
  • Should I use a dedicated map object that represents the table and query with that instead?
  • 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-23T14:54:50+00:00Added an answer on May 23, 2026 at 2:54 pm

    If you want to map that design, you need a third entity, that I’ll call Participation.

    • One user has many participations;
    • One channel has many participations;
    • One participation has one channel, one user, and 5 boolean fields (status1 to status5)

    But a more normal (and certainly easier to query) way of designing this would be to have a Participation entity with just one status, and create a Participation instance per User-Channel-Status tuple. If you think about it, it would be the only possible mapping (as far as I see) if the number of possible statuses was much bigger (or not fixed at all).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.