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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:47:33+00:00 2026-05-12T09:47:33+00:00

How should I do if I have two tables and their primary keys have

  • 0

How should I do if I have two tables and their primary keys have the same name like the following XML mapping file suggests?

<class name="Person" table="person">

    <id name="uid_" type="java.lang.String" column="uid">
        <generator class="native" />
    </id>

    <property name="name_" type="java.lang.String" column="pName" />
    <property name="age_" type="integer" column="age" />
    <property name="birthday_" type="date" column="birthday"/>

    <many-to-one name="school" class="School" column="schoolID" unique="false" />

    <bag name="course">
        <key column="uid" />
        <many-to-many class="Course" column="uid" />
    </bag>

  </class>

The Person and Course’s primary key both named “uid”. The hibernate says “Repeated column in mapping”.

  • 1 1 Answer
  • 1 View
  • 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-12T09:47:34+00:00Added an answer on May 12, 2026 at 9:47 am

    Change the name given to the column in the many to many relation.

    <bag name="course">
            <key column="uid" />
            <many-to-many class="Course" column="course_uid" />
    </bag>
    

    The column in the relation mapping isn’t an identifier of the course’s column, it is just the name to be used in the relation table.

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

Sidebar

Related Questions

If I have a relationship between two tables (both tables have their own primary
Imagine I have two tables in a DB like so: products: product_id name ----------------
I have two tables that should be joined together by a foreign key relationship,
I have two tables. Both tables are editable and both tables should allways be
This should be so simple, but I'm drawing a blank. I have two tables.
I have two divs which should looks like one figure. The problem is with
Should a database table that contains two columns that are foreign keys have a
I have two tables Product having following structure: ProductID,ProductName, IsSaleTypeA, IsSaleTypeB, IsSaleTypeC 1, AAA,
I have two tables User id name Result id user_id score created_at Every hour
I have two tables: books (id, name, desc, instance_id) instances (id, domain) A user

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.