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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:17:06+00:00 2026-05-16T05:17:06+00:00

I have an existing database that I am now connecting to using hibernate. I

  • 0

I have an existing database that I am now connecting to using hibernate. I cannot change the data in it at the moment and have everything working apart from a single column.

I have a status column that has the values:

  • new
  • mailed
  • in
  • out

And the column is mapped as follows:

@Column(name = "STATUS", nullable = false, length = 50)
@Enumerated(EnumType.STRING)
private TeamMemberStatus status;

I would REALLY like (for application reasons) to have this column mapped as a Java Enum (TeamMemberStatus), but due to the fact that ‘new’ is a keyword in Java I cannot have that as an enum member.

If I have the enum contstants NEW, MAILED, IN and OUT hibernate fails as inside EnumType it does a Enum.valueOf().

Is there any way for me to map this to my Enum without having to write a complex UserType?

— added content

My Enum like this:

public enum TeamMemberStatus {
    NEW, MAILED, IN, OUT 
}

is a valid Java enum, but not matching the case of the database. If I change it to match the database like:

public enum TeamMemberStatus {
    new, mailed, in, out
}

It won’t compile as ‘new’ is a Java reserved word.

  • 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-16T05:17:07+00:00Added an answer on May 16, 2026 at 5:17 am

    If you can use a SQL UPPER statement at database, It will work without using any UserType

    UPDATE

    Well, It can not be The nicest solution but it solves what you want

    @Entity
    public class WrapperEntity {
    
       private TeamMemberStatus memberStatus;
    
       @Transient
       private TeamMemberStatus getMemberStatus() {
           return this.memberStatus;
       }
    
       public void setMemberStatus(TeamMemberStatus memberStatus) {
           this.memberStatus = memberStatus;
       }
    
       @Column(name="STATUS", nullable=false, length=50)
       public String getMemberStatusAsString() {
           return memberStatus.name().toLowerCase();
       }
    
       public void setMemberStatusAsString(String memberStatus) {
           this.setsetMemberStatus(TeamMemberStatus.valueOf(memberStatus.toUpperCase()));
       }
    

    }

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

Sidebar

Related Questions

I have an existing database that has some testing data into and I'm interested
I have an existing database based on SQLiteOpenHelper that has several versions and code
I currently have an existing database and I am using the LINQtoSQL generator tool
I'm working on a PHP-based webapp that has an existing MySQL database where all
I have currently existing database and hibernate mapping for it. There is a central
I have an existing database, which I have been happily accessing using LINQtoSQL. Armed
For whatever reason, I have a lot of clients that have existing data that's
I have an existing NHibernate 2.1.2.4000 mapping that uses the mapping syntax: <database-object> <create>
I have an existing database with the table Transactions in it. I have added
I have an existing database of a film rental system. Each film has a

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.