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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:08:39+00:00 2026-06-17T08:08:39+00:00

I have two tables: the primary table, Order, and the other table, Status. Order

  • 0

I have two tables: the primary table, Order, and the other table, Status. Order has a foreign key, status_id. Status is a table of the following Strings: “Complete”, “In transit”, or “Pending”. Am I right in saying that what I would usually implement is two entities, Order and Status, where the Order entity has a Many-to-one mapping for the foreign key? The reason I think it would be a many to one mapping is because each Order only has one Status, but the Status values will obviously be reused (e.g., a bunch of different Orders could have a status of “In transit”).

However, I have one additional question. Since the “Status” table is going to be a simple table with only one String column, and only with 3 rows, is there an easier way to implement it in Hibernate? Does it actually have to be an entity or is there some value based mapping I can use?

Also, please make any examples mapping based (XML)… I am using hibernate mapping files, not annotations or anything else.

  • 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-17T08:08:40+00:00Added an answer on June 17, 2026 at 8:08 am

    If your status table is only strings, I would suggest you collapse your status_id to a character column in your order table and use a Enum to encode the various statuses. You can add an extra getter method to return the Enum instead of the status. In your enum class, you can have the descriptive strings and you can have them as nouns, verbs etc.

    Here is an example enum template I use in Eclipse for this purpose:

    public enum Status {
    
    COMPLETE("complete"),
    IN_TRANSIT("In transit"); // You can add others here.
    
    private String _id;
    
    
    private Status(String id) {
        _id = id;
    }
    
    private static Map<String, Status> _enumById = new HashMap<String, Status>();
    
        static {
            for (${enclosing_type} type : values()) {
                 _enumById.put(type.getId(), type);
            }
        }
    
    
        public String getId() {
            return _id;
        }
    
    
        public static Status findById(String id) {
            return _enumById.get(id);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with primary foreign key relationship. The table in foreign key
I have two SQL Server tables with Primary Keys (PK) and a Foreign Key
i have two tables both are related with primary-foreign key ralation and i have
I have two tables, the first has a primary key that is an identity,
I have two database tables with the following structure: actions: action_id int(11) primary key
I have two tables, each one has a primary ID column as key. I
I have got two tables. One is a User table with a primary key
I Have two tables: Home(ID, name) and Photos(ID, homeid, filename, splash) Home primary key
I have two SQL statements: CREATE TABLE legs(legid INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
I have a two-column primary key on a table. I have attempted to alter

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.