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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:04:28+00:00 2026-05-25T22:04:28+00:00

This is with EclipseLink via JPA, where I let it create the tables for

  • 0

This is with EclipseLink via JPA, where I let it create the tables for me. The back end data base is Derby for development mode, and I expect to use MySQL or something else for deployment.

In my entity I have an enum:

@Entity
public class Thing implements Serializable {

    public enum Choice { Able, Baker, Charlie, Delta }

    @Column(precision = 1)
    private Choice  choiceValue;

    // etc
}

The enum ordinal only needs one digit, but when the table gets created it allocates 10 digits for it. So a million records will waste 9 Megabytes. The “precision = 1” term is ignored.

Is there a way to cause it to use just one byte to encode the enum?

  • 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-25T22:04:28+00:00Added an answer on May 25, 2026 at 10:04 pm

    Setting scale or precision for Integer column where enum is mapped in Derby & EclipseLink does not help. It does nothing, you will end up with INTEGER anyway. You can have more control with following.

    @Column(columnDefinition = "SMALLINT") //smallint= 2 bytes or
    //@Column(columnDefinition = "NUMERIC(1)") //
    private Choice  choiceValue;
    

    It had worked for me, but basically Java type for NUMERIC is BigDecimal and for SMALLINT short, maybe that can produce problems in some cases. For example native queries will return BigDecimal for choiceValue-column.

    How much storage is needed depends bit about database provider, some older MySQL stored character per digit, now it seems to be quite fine tuned: http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html I don’t know how it is exactly in Derby, but I would assume it not taking more than byte.

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

Sidebar

Related Questions

If I use JPA (EclipseLink) to create tables a String type results in a
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I want to use JPA (eclipselink) to get data from my database. The database
I am using this JPA-Query (EclipseLink): SELECT e FROM Entity e GROUP BY e.label
This is similar to How to cascade persist using JPA/EclipseLink I have to entities
I am creating an application with eclipselink JPA, I am using HistoryPlicy to create
I'm using spring mvc 3.0 with eclipselink and jpa and I'm experiencing following issue:
I'm playing around a bit with JPA(Eclipselink to be specific). The below entity have
I'm making my first steps with JPA (eclipselink) developement, and i'm wondering if there's
I have a running web service (using EclipseLink as JPA provider) and would like

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.