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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:54:35+00:00 2026-06-05T22:54:35+00:00

I have a site with multiple pages, and each page has a table that

  • 0

I have a site with multiple pages, and each page has a table that contains some data. The tables have many columns, and users can select which columns to display or hide. I am trying to persist these selections.

The question I have is choosing the best way to persist these objects.

I see many possible ways, none of which Ive had success in implementing. But before I commit to one of them, I would like to know if I am doing it horribly wrong, or am way off the mark with how this should be implemented.

I have a user class that is persisted already.

Option #1
In my user entity, add a field of Map> where the key is the page name, and the list is the columns the user has selected on that page. Using @ElementCollection.

Option #2
User entity has a @onetomany List. Which requires a UserColumns entity, with pagename as primary key, and @oneToMany relationship with another entity for each column.

Option 1:

@Entity
public class User{

private Map<String, List<String>> columns;

@ElementCollection
public void setColumns(Map<String, List<String>> colunms){

}


}

Option 2:

@Entity
public class User{

private List<UserColumns> columns;

@ElementCollection or @OneToMany
public void setColumns(List<UserColumns> colunms){

}


}

I realize this will be difficult to answer without looking at the actual code, and I’ve probably not described the situation adequately or precisely, but welcome all input anyways. Thank you.

  • 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-05T22:54:36+00:00Added an answer on June 5, 2026 at 10:54 pm

    I personally always prefer to use a one to many relationship to other entities when doing something like this. My reason is that it is a much more flexible design going forward. It is pretty easy to see a scenario where instead of just knowing the column name you will want additional information. By using a real entity instead of a string you simply add a new property to your class. If you are using just a string though you will have a much more extensive refactoring on your hands. Takes a little longer in the beginning but it almost always pays off in the end.

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

Sidebar

Related Questions

I have a page on my site which has multiple drop down boxes as
I an writing a website that will have multiple skins. Each skin has its
I'm building a site that has items, with each item having a page, for
I'm currently managing multiple models from a single SITE MANAGER page. I have the
I have a site in multiple languages. I have a method that returns me
I have a problem with my site. The site has multiple entities: Articles, Posts,
I have multiple divs on the site! for example <div id='id_111232'>Some text</div> <div id='id_111233'>Some
I have a set of aspx pages that each live in their own directory
I have written a user control that captures some user input and has a
On this site each page is made up of multiple .jsp files. There 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.