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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:59:39+00:00 2026-05-28T00:59:39+00:00

We have a table in our system that stores resource key/value pairs. There are

  • 0

We have a table in our system that stores resource key/value pairs. There are two columns to store the value; a VARCHAR column for smaller values and a CLOB for larger values. On the Java side, they are instantiated into one of two classes, a StandardResourceBundleValue or a LargeResourceBundleValue, and a discriminator column is used to distinguish them in the one table:

<discriminator type="string">
    <column name="RESOURCE_TYPE" length="20" index="XIE1CPD_RESOURCE_BUNDLE_L_V"/>
</discriminator>
...
<subclass name="StandardResourceBundleValue" discriminator-value="STANDARD">
    <property name="messageValue" type="string" column="STD_MSG_VALUE" length="400"/>
</subclass>
<subclass name="LargeResourceBundleValue" discriminator-value="LARGE">
    <property name="messageValue" type="materialized_clob" column="LARGE_MSG_VALUE"/>
</subclass>

Here’s the fun part: If the value of a key started out small (and persisted as a StandardResourceBundleValue) then the value changes to one larger than the VARCHAR, we need a way to convert it to a StandardResourceBundleValue. The code this is happening in can’t just delete the StandardResourceBundleValue and create a LargeResourceBundleValue, because that’s causing constraint violations.

What we would like to do is define a property for that discriminator column, so the base class can have a method that changes that value in the object, so when it’s persisted again it will save the value in the CLOB.

<property name="resourceType" type="string">
    <column name="RESOURCE_TYPE"/>
</property>    

When I try building the table, I get the following error:

Repeated column in mapping for entity:
com.foo.resourcebundle.LargeResourceBundleValue column:
RESOURCE_TYPE (should be mapped with insert=”false” update=”false”)

Clearly it doesn’t understand what I’m trying to do, but it makes sense that there should be a way of doing it. So how do you expose a discriminator field as a property?

Thanks.

  • 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-28T00:59:40+00:00Added an answer on May 28, 2026 at 12:59 am

    You can’t do that. An object has a type, and it can’t switch from one type to another. That’s just how Java works.

    I think you just shouldn’t have two types of entities here. Why don’t you just store the discriminator as a basic enum column, and store/fetch the value of the property in the varchar or clob column based on the value of this enum. Make sure everything is transparently encapsulated into the object, and everything will be easier, even for callers. The enum field could even not be made public. You use it to implement getMessageValue() (get the value from the appropriate column), and you change its value when setMessageValue() is called, based on the length of the new value.

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

Sidebar

Related Questions

We have a table in our system that would benefit from a numeric column
We have a table that is used for assessment-values in our tool where each
We have two tables in our application that both have a ShowOrder column. We
I have table with some fields that the value will be 1 0. This
I have the following problem: Our system has products that when released only are
I am using SQL Server 2008. I have a table (TBL_FILE) that stores user
We've encountered the following situation in our database. We have table 'A' and table
I have a table containing data about some users. Many of them use our
We are currently using a summary table that aggregates information for our users on
I have three tables: unmatched_purchases table: unmatched_purchases_id --primary key purchases_id --foreign key to events

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.