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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:48:44+00:00 2026-05-24T12:48:44+00:00

I’m looking for the best solution to store Java EE application’s global data using

  • 0

I’m looking for the best solution to store Java EE application’s global data using Hibernate. It will consist of key value pairs. Example:

projectStarted = "10-11-11"
developerNumber = 3
teamLeader = "John"

As you see, all of this entries have different types.

For now I see two options:

1) Create GlobalData entity. Each field of it will be represented as unique column in the table and will contain unique setting. This way I have no problems with type casting, but I would like to avoid it in case where there will be big amount of settings.

2) Create Setting entity. Each of it will contain two fields: key(Primary key) and value and will be represented as unique record in the table. This is preferable solution, but It’s seems to me that I will get a lot of type casting, because settings can be any type.

So basically, I’m looking for the way to implement second solution without getting a lot of troubles from different types. Can anybody help me?

Thanks.

Edit 1.

Yeah, thanks Christian. Just got similar idea.

What if I will have Settings entity, which will be like:

@Entity
@Table(name = "settings")
public class Setting {

    @Column
    private String key;
    @Column
    private String value;
    @Column
    private String converterClassFullName; //example by.lugovsky.MyConverter

    //Getters, setters
}

And GlobalData class.

public class GlobalData {
    private Date projectStarted;

    private int developerNumber;

    private String teamLeader;

    Set<Setting> settings;

    //Getters and setters for all, except settings.

}

So basically my idea is to convert Setting entity before persisting/updating/ etc. I can do this in my DAO, but I was wondering, if I could annotate GlobalData class with @Entity annotation as well without creating new table. This way I can set OneToMany annotation to Setting’s set and Perform conversions in the internal @PrePersist etc. methods.

Will Hibernate allow me to do this?

Thanks again

  • 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-24T12:48:45+00:00Added an answer on May 24, 2026 at 12:48 pm

    You could store a Converter-Class into the db and the let it run through the given converter for a property before using the value. JSF offers Converter API:

    public interface Converter{
        public Object getAsObject(FacesContext fc, UIComponent component, String value) throws ConverterException;
    
        public String getAsString(FacesContext fc, UIComponent component, Object obj) throws ConverterException;
    }
    

    If you have a schema with

    name: String

    value: String

    converter: Class

    then you could do something like this:

    PropertyEntry pe = // Get from OR-Mapper
    Converter c = (Converter) pe.getConverter().newInstance();
    Object o = c.getAsObject(null, null, pe.getValue());
    // use the object o instead of value
    

    For even more coolness you could also define a field in the class which will not be persisted which you could use to hold the converted value within the object.

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

Sidebar

Related Questions

I'm looking for suggestions for debugging... If you view this site in Firefox or
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.