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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:39:22+00:00 2026-05-14T03:39:22+00:00

I’ve started a rather large Enum of so called Descriptors that I’ve wanted to

  • 0

I’ve started a rather large Enum of so called Descriptors that I’ve wanted to use as a reference list in my model. But now I’ve come across a compiler/VM limit the first time and so I’m looking for the best solution to handle this.

Here is my error : The code for the static initializer is exceeding the 65535 bytes limit

It is clear where this comes from – my Enum simply has far to much elements. But I need those elements – there is no way to reduce that set.

Initialy I’ve planed to use a single Enum because I want to make sure that all elements within the Enum are unique. It is used in a Hibernate persistence context where the reference to the Enum is stored as String value in the database. So this must be unique!

The content of my Enum can be devided into several groups of elements belonging together. But splitting the Enum would remove the unique safety I get during compile time. Or can this be achieved with multiple Enums in some way?

My only current idea is to define some Interface called Descriptor and code several Enums implementing it. This way I hope to be able to use the Hibernate Enum mapping as if it were a single Enum. But I’m not even sure if this will work. And I loose unique safety.

Any ideas how to handle that case?

  • 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-14T03:39:23+00:00Added an answer on May 14, 2026 at 3:39 am

    My original idea was to map the Enum using the @Enumerated annotion. This would have looked like the following example:

    @Enumerated(STRING)
    private DescriptorEnum descriptor;
    

    The database would have a column called DESCRIPTOR of type varchar and Hibernate (in my case) would map the string to the enumeration.

    But I have that limit of 65k (see question) which is to small in my case. But I’ve found a solution. Have a look at the following example:

    public final class Descriptor {
        public final String acronym;
        private static final Hashtable<String, Descriptor> all = new Hashtable<String, Descriptor>();
        static {
            initialize();
        }
        private static void initialize() {
            new Descriptor("example001");
            new Descriptor("example002");
            new Descriptor("example003");
        }
        private Descriptor(String acronym) {
            this.acronym = acronym;
            if (all.contains(this.acronym)) {
                throw new RuntimeException("duplicate acronym: " + this.acronym);
            }
            all.put(this.acronym, this);
        }
        public static Descriptor valueOf(String acronym) {
            return all.get(acronym);
        }
        public String value() {
            return this.acronym;
        }
    }
    

    This Descriptor class simulates the usage of a typical enum. But now I’m able to split the initialize() method into several ones that work around the 65k limit that also exists for methods. The Enum doesn’t allow to split the initialization into several chunks – my class does.

    Now I have to use a slightly different mapping though:

    @Column(name = "DESCRIPTOR")
    private String                  descriptorAcronym       = null;
    private transient Descriptor    descriptor              = null;
    public Descriptor getDescriptor() {
        return descriptor;
    }
    public void setDescriptor(Descriptor desc) {
        this.descriptor = desc;
        this.descriptorAcronym = desc != null ? desc.acronym : null;
    }
    public String getDescriptorAcronym() {
        return descriptorAcronym;
    }
    public void setDescriptorAcronym(String desc) {
        this.descriptorAcronym = desc;
        this.descriptor = desc != null ? Descriptor.valueOf(desc) : null;
    }
    @PostLoad
    private void syncDescriptor() {
        this.descriptor = this.descriptorAcronym != null ? Descriptor.valueOf(this.descriptorAcronym) : null;
    }
    

    This way I can use the class like an Enum in most cases. It’s a bit tricky… but it seems to work. Thanks for all the input that finally led me to that solution.

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

Sidebar

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.