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

  • Home
  • SEARCH
  • 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 9138511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:15:58+00:00 2026-06-17T09:15:58+00:00

Given the tables: TableA aId … TableB bId … TableC aId cId // Maps

  • 0

Given the tables:

TableA
aId
...

TableB
bId
...

TableC
aId
cId // Maps to TableB.bId

In other words TableA and TableB are only related through an entry in TableC.

I want the following classes:

public class ClassA
{
    aId
    ...
}

public class ClassB
{
    bId
    ...
}

public class ClassD : ClassA
{
   ClassB
}

So that ClassD has all of the properties of ClassA with the addition of a single instance of ClassB.

My initial thought was to use:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping auto-import="false" xmlns="urn:nhibernate-mapping-2.2">
  <class name="ClassD" lazy="false" table="TableA" polymorphism="explicit">
    <id name="aId" column="aId" type="Guid">
      <generator class="CustomGuidGenerator" />
    </id>
    ...
    <many-to-one name="ClassB" column="cId" class="ClassB" cascade="all" not-found="ignore" />
  </class>
</hibernate-mapping>

Obviously, in this mapping, there is no cId in TableA nor is there a way in many-to-one to specify a table. So, how do you map a single entity via an intermediate join table?

  • 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-06-17T09:15:59+00:00Added an answer on June 17, 2026 at 9:15 am

    Not sure what is exactly in your tables (is TableC.aId a reference to TableA.aId ?), but maybe you can go for a table-per-subclass strategy ( see for example http://docs.huihoo.com/hibernate/nhibernate-reference-1.2.0/inheritance.html )

    <class name="ClassA" table="TableA">
      <id name="aId" column="aId" type="Guid">
        <generator class="CustomGuidGenerator" />
       </id>        
        <joined-subclass name="ClassD" table="TableC">
            <key column="aId"/>
            <many-to-one name="ClassB" column="cId" class="ClassB" cascade="all" not-found="ignore" />
        </joined-subclass>
    </class>
    

    About ClassB, it should have it’s own mapping file, and the system will be able to compute the table name (TableB) for the many-to-one ClassB property.

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

Sidebar

Related Questions

In SQL Server 2008 and given TableA(A_ID, A_Data) TableB(B_ID, B_Data) ViewC(A_or_B_ID, A_or_B_Data) is it
I've two tables: TableA and TableB, joined by TableA.TableA_Id->1..n<-TableB.TableA_Id. A simple PK-FK. I need
Given these tables: create table Orders ( Id INT IDENTITY NOT NULL, primary key
What is the use of the below given tables in Joomla Database? jos_core_acl_aro jos_core_acl_aro_groups
Given two tables APPLE and ORANGE, NAME APPLES Alice 5 Bob 10 Trudy 1
given the two tables and values: Tables People- Columns: [ID]PK Name Field - Columns:
Given the following tables orders +----+---------+---------+ | id | user_id | details | +----+---------+---------+
Given the following tables: Topic id, last_updated_child_id Response id, topic_id, updated_at How do I
Given the following tables: shows: title | basic_ticket_price ----------------+-------------------- Inception | $3.50 Romeo &
Given the following Tables: Names Id int Name varchar Properties Id int NameId varchar

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.