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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:41:23+00:00 2026-05-11T12:41:23+00:00

I have a table DEAL and a table DEAL_TYPE. I would like to map

  • 0

I have a table DEAL and a table DEAL_TYPE. I would like to map this code:

public class Deal {    DealType type; }  public enum DealType {    BASE('Base'), EXTRA('Extra'); } 

The problem is that the data already exist in the database. And I’m having a hard time mapping the classes to the database.

The database looks something like that:

   TABLE DEAL {       Long id;       Long typeId;    }     TABLE DEAL_TYPE {        Long id;        String text;    } 

I know I could use a simple @OneToMany relationship from deal to deal type, but I would prefer to use an enum. Is this possible?

I almost got it working by using a EnumType.ORDINAL type. But unfortunately, my IDs in my deal type table are not sequential, and do not start at 1.

Any suggestions?

  • 1 1 Answer
  • 1 View
  • 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-11T12:41:23+00:00Added an answer on May 11, 2026 at 12:41 pm

    Hibernate is kind of terrible at Enums. It’s a strange failing of an otherwise pretty good ORM. The ‘easiest’ way to get around it is to declare your Enum a custom hibernate type. Fortunately, Hibernate wrote an example implementation which you can crib verbatim into your app:

    http://www.hibernate.org/265.html

    They even include instructions on how to use it. This is the pattern I use whenever I end up with the need to persist enums.

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

Sidebar

Ask A Question

Stats

  • Questions 247k
  • Answers 247k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It certainly isn't a C# issue - VB.NET has the… May 13, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer According to this introduction, you'll need at least the following… May 13, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer No, it shouldn't "just coerce". Regarding the following: sql.eachRow("{call getnodes()}")… May 13, 2026 at 8:45 am

Related Questions

I have been programming in C# and Java for a little over a year
I seem to often find myself wanting to store data of more than one
I've got a search box that users can type terms into. I have a
I have a question about the SQL standard which I'm hoping a SQL language

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.