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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:38:05+00:00 2026-05-16T17:38:05+00:00

I have a few simple entities that are stored in a simple code table

  • 0

I have a few simple entities that are stored in a simple “code” table with the following structure (all stored as character fields):

code_fieldname   pk
code_value       pk
code_comment
code_field1
code_field2

One object I am trying to map has data stored in this table of the following form

code_fieldname = "segment"
class = Segment
segment.id = code_value
segment.name = code_comment
segment.markup = code_field1 (decimal property)

So the segment records all have a “code_fieldname” = “segment” with their ID being the value of “code_value”.

What is the mapping for such a structure? I am using XML based mapping.

  • 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-16T17:38:06+00:00Added an answer on May 16, 2026 at 5:38 pm

    I’ve managed to solve this first by using inheritance for the class, and then using a formula property on the relationship. Definition for the entities follow:

    <class name="GeneralCode" table="code_mstr">
      <composite-id name="key">
        <key-property name="key" column="code_fieldName" type="string"/>
        <key-property name="value" column="code_value" type="string"/>
      </composite-id>
      <discriminator column="code_fieldName" type="string" insert="false"/>
      <subclass name="Segment" discriminator-value="segment">
        <property name="name" type="string" column="code_comment"/>
      </subclass>
    </class>
    

    Now I can use this in a relationship like the following:

    <many-to-one name="segment" class="Segment"
                 lazy="false" insert="false" update="false">
      <formula>'segment'</formula>
      <column name="segment"/>
    </many-to-one>
    

    Note that the formula requires the quoted ‘segment’ value as this is always the fields key, i.e. code_fieldname = ‘segment’ in all cases.

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

Sidebar

Related Questions

I have few simple queries, that display rows from a table in a database.
I have a few simple scripts that are intended to daisy chain together to
I have written a small makefile for a few simple C programs that compiles
I have a simple html form with few fields in it. I wanted to
I have simple win service, that executes few tasks periodically. How should I pass
I have few simple django-based sites and I their number increasing all the time.
I have few lines of C++ code which has simple purpose - to store
I have a website that has an index.php, a few simple .html pages and
In my application, I've got a few different types of entities that I have
I have few tables that have the same structure (e.g. Queue1, Queue2, etc.). I

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.