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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:55:43+00:00 2026-05-11T07:55:43+00:00

Most projects have some sort of data that are essentially static between releases and

  • 0

Most projects have some sort of data that are essentially static between releases and well-suited for use as an enum, like statuses, transaction types, error codes, etc. For example’s sake, I’ll just use a common status enum:

public enum Status {     ACTIVE(10, 'Active');     EXPIRED(11, 'Expired');     /* other statuses... */      /* constructors, getters, etc. */ } 

I’d like to know what others do in terms of persistence regarding data like these. I see a few options, each of which have some obvious advantages and disadvantages:

  • Persist the possible statuses in a status table and keep all of the possible status domain objects cached for use throughout the application
  • Only use an enum and don’t persist the list of available statuses, creating a data consistency holy war between me and my DBA
  • Persist the statuses and maintain an enum in the code, but don’t tie them together, creating duplicated data

My preference is the second option, although my DBA claims that our end users might want to access the raw data to generate reports, and not persisting the statuses would lead to an incomplete data model (counter-argument: this could be solved with documentation).

Is there a convention that most people use here? What are peoples’ experiences with each and are there other alternatives?

Edit:

After thinking about it for a while, my real persistence struggle comes with handling the id values that are tied to the statuses in the database. These values would be inserted as default data when installing the application. At this point they’d have ids that are usable as foreign keys in other tables. I feel like my code needs to know about these ids so that I can easily retrieve the status objects and assign them to other objects. What do I do about this? I could add another field, like ‘code’, to look stuff up by, or just look up statuses by name, which is icky.

  • 1 1 Answer
  • 4 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. 2026-05-11T07:55:44+00:00Added an answer on May 11, 2026 at 7:55 am

    We store enum values using some explicit string or character value in the database. Then to go from database value back to enum we write a static method on the enum class to iterate and find the right one.

    If you expect a lot of enum values, you could create a static mapping HashMap<String,MyEnum> to translate quickly.

    Don’t store the actual enum name (i.e. ‘ACTIVE’ in your example) because that’s easily refactored by developers.

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

Sidebar

Related Questions

In most cases we work together in projects but most of us have some
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
Most mature C++ projects seem to have an own reflection and attribute system ,
Most projects now need some form of a database. When someone says database, I
We use SQL Server 2000/2005 and Vault or SVN on most of our projects.
Unquestionably, I would choose to use the STL for most C++ programming projects. The
I've got a question about references between projects in a solution. Most of my
I have some code that does something like this (Irrelevant bits snipped): void foo(Bitmap
I realized that many of my past projects have suffered from too much ajax.
I always end up needing the user's location on most web projects that I

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.