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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:32:46+00:00 2026-05-30T15:32:46+00:00

We have some legacy database mappings in GORM and several have a primary key

  • 0

We have some legacy database mappings in GORM and several have a primary key which is an enumeration. The enumeration are stored using the string values, not the ordinals.

For example:

class AccountingGLMap {
    AccountingTypeCode id
    String typeCode

    static mapping = {
        id(column: 'accountingTypeCode',  generator: 'assigned')
    }
}

When you try to retrieve an instance, you get:

| Error 2012-02-23 10:32:41,319 [pool-5-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize

I have verified that the values in the table map properly into the enumeration given (I can instantiate the object with the Enum so long as it’s not the primary key). If we change the Enum to a String, everything works fine.

I did see an article claiming you can’t use an Enum as the primary key when using JPA, but even that was disputed.

Anyone have experience doing this?

EDIT: For reference we are using 2.0.1 against an Oracle database.

  • 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-30T15:32:47+00:00Added an answer on May 30, 2026 at 3:32 pm

    Add type: 'string' to your id mapping and then add a setter for id that takes a String input like so:

    class AccountingGLMap {
        AccountingTypeCode id
        GLTypeCode glTypeCode
    
        static mapping = {
            id(column: 'accountingTypeCode', type: 'string', generator: 'assigned')
        }
    
        void setId(String value) {
            id = value
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy database with a field which contains some parentheses, like red(b).
I have a legacy database in which data is stored in a way similar
I have a name in a database, lets say its DFectuoso and some legacy
We have some legacy code that needs to identify in the Page_Load which event
Presently I have a some legacy code, which generates the op code. If the
I have to insert some records in a table in a legacy database and,
I have the following scenario: Due to an unfortunate legacy database, I have some
I have a legacy database that I've set up some models to use. The
I'm working with a legacy database in Oracle and some of my tables have
I am using Entity Framwork DbContexts with a legacy database. I have 2 different

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.