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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:03:54+00:00 2026-05-27T22:03:54+00:00

I am working on a restaurant app using Hibernate. I have several entities like

  • 0

I am working on a restaurant app using Hibernate. I have several entities like Pizza, Beverage, Pasta etc.

I want these to be persisted to different tables but have primary keys that are unique among all.
i.e if I say itemId 4 it should be sufficient to identify any of the food items available.

Any idea how to do it guys?

I would prefer a solution using Hibernate annotations. 😐

  • 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-27T22:03:54+00:00Added an answer on May 27, 2026 at 10:03 pm

    An UUID would be unique for all tables, but you won’t be able determine which the table is based on the id only.

    To be honest, this is a bit strange requirement. But if you really insist on it, you can simply prefix the table/entity name to the primary key. For that you’d need a custom generator. See this question.

    You can use inheritance. Have a base entity @MappedSuperclass Item, with @Inheritance strategy set to table-per-class and then Pasta, Pizza. If the fields don’t differ much you use even single-table strategy with a discriminator column. And if your entity types are likely to grow, you can simply have one Item with a column type

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

Sidebar

Related Questions

I'm working on a restaurant CMS app. I have a many-to-many relationship between 2
I have a web app for restaurant order management build using servlet/jsp. I have
I have two asynctask working with each other. I'm using them for creating Restaurant
I want to write app for company where i'm working. It will work only
I have a php script that's not working correctly. when i test it using
I'm working on a restaurant site and I have specific ordering hours. How do
Help! Please! I am working with a restaurant POS system using crystal reports. I
I'm working on an online food delivery site using ASP.NET/C#, I have a page
This is the first time I'm using this website, I have recently started working
I am working on an app that posts restaurant information to the user's Facebook

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.