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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:46:25+00:00 2026-06-13T00:46:25+00:00

I have an enumerated type field current_status in a table history in a PostgreSQL

  • 0

I have an enumerated type field current_status in a table history in a PostgreSQL database. The enumeration is defined as:

CREATE TYPE et_status AS ENUM
   ('PENDING', 'SUCCESS', 'LATE', 'EARLY', 'FAILED', 'IN_PROGRESS', 'EXPIRED');

I added an enumerated type on the server side and made some changes to the type on the relevant field and the getter and setter. This looks like:

@Entity
@Table(name = "history")
@XmlRootElement
@NamedQueries({ ... })
public class History implements Serializable {
    public enum StatusType implements Serializable
        {PENDING, SUCCESS, SUCCESS_LATE, SUCCESS_EARLY,
         FAILED, IN_PROGRESS, EXPIRED};

...

    @Lob
    @Column(name = "current_status")
    private StatusType currentStatus;

...

    public StatusType getCurrentStatus() {
        return currentStatus;
    }

    public void setCurrentStatus(StatusType currentStatus) {
        this.currentStatus = currentStatus;
    }
}

When testing the web service, I get the following error:

The object [PENDING], of class [class org.postgresql.util.PGobject], from mapping
[org.eclipse.persistence.mappings.DirectToFieldMapping[currentStatus-->history.current_status]]
with descriptor [RelationalDescriptor(entities.History --> [DatabaseTable(history)])],
could not be converted to [class java.lang.Integer].

Searching the Internet yielded this solution, but it appears to require the use of org.hibernate.annotations.TypeDef which I don’t seem to have in my installation.

Question: What is the proper method of converting from a PostgreSQL enumerated type into a Java enumerated type via a RESTful Web Service?

Database: PostgreSQL 8.4
App Server: Glassfish 3.1.2.2
IDE: NetBeans 7.2
JDK: 7 update 7

  • 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-13T00:46:26+00:00Added an answer on June 13, 2026 at 12:46 am

    Don’t use @Lob, try @Enumerated(EnumType.STRING) instead.

    However you have to make sure then that the names in java exactly match those in postgresql (which they don’t in your current code).

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

Sidebar

Related Questions

I have an enumerated type, StackID , and I am using the enumeration to
I have an XSD file with an enumerated type. I'd like to create an
If I have a type defined as a set of an enumerated type, it's
Possible Duplicate: How do I enumerate an enum? Say I have an enum type
Let's assume, that we have an enumered type: enum DataType { INT, DOUBLE };
I have the following enumerated type: /// <summary> /// TTE Node types. /// </summary>
I have an enumerated data type in a socket library for PUT, POST, and
I have a class with an enumerated type GameStates. In the (public) constructor I
Arrays can be indexed using user-defined enumerated types. For example: type TIndexValue = (ZERO
I have an enumerated type that I would like to define the > ,

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.