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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:52:06+00:00 2026-06-15T18:52:06+00:00

In my project I use an enum in some entities. The enum is to

  • 0

In my project I use an enum in some entities. The enum is to be stored in the database as an integer. To achieve this I use EclipseLink’s ObjectTypeConverter.

I’d like to use annotations since I use Spring to omit the persistence.xml. The annotation to configure the ObjectTypeConverter must be specified on an entity. I don’t feel the need to specify the annotation on all classes that use this enum as this is redundant and not maintainable. Specifying it once on some entity would work but this doesn’t make sense in an OOP design (or any design for that mater). A solution would be to annotate the enum with @ObjectTypeConverter, but this doesn’t work since the enum isn’t an entity.

Example that isn’t working but would be ideal:

@Entity
public class ExampleEntity
{
    @Id
    private Long id;
    @Convert("exampleenum")
    private ExampleEnum ee;
}

@ObjectTypeConverter(name = "exampleenum", objectType = ExampleEnum.class, dataType = Integer.class,
    conversionValues =
        {
            @ConversionValue(objectValue = "A", dataValue = "100"),
            @ConversionValue(objectValue = "B", dataValue = "200"),
            @ConversionValue(objectValue = "C", dataValue = "300")
        })
public enum ExampleEnum
{
    A, B, C;
}

Example results in the following exception:

Exception Description: The converter with name [exampleenum] used with the element [field ee] in the class [class com.example.ExampleEntity] was not found within the persistence unit. Please ensure you have provided the correct converter name.

Since I’m using Spring, JPA and EclipseLink I accept any answer using these frameworks.

  • 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-15T18:52:07+00:00Added an answer on June 15, 2026 at 6:52 pm

    Upon reading the documentation (which I should have done more carefully in the first place) I noticed:

    An ObjectTypeConverter must be be uniquely identified by name and can be defined at the class, field and property level and can be specified within an Entity, MappedSuperclass and Embeddable class.

    I couldn’t annotate the enum with @Entity (as this requires a table) or @MappedSuperclass (as this doesn’t make sense), but @Embeddable would make sense in a way. Marking the enum with @Embeddable did the trick:

    @Embeddable
    @ObjectTypeConverter(...)
    public enum ExampleEnum
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our project we use Zend Framework Model generator, which produces something like this
I would like to use my own enum in a project setting (from Visual
At my project I use Spring Security and GWT with url-like internationalization (http://....html?locale=en). Login
I have an AS3 project making use of compile time constants. This has worked
I use a enum for describe different project states: [Flags] public enum ProjectStatus {
I've created Java annotations (since I need run time retention) under $PROJECT/src/main/java and my
In my project I'd like to use T4 to generate my enums. To test
When I compile our project use Delphi 2010 Trial, there has a fatal error
I try to run my project in windows. Project use android ndk. I install
For my project I use rake test for testing my libs. For example, I've

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.