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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:41:07+00:00 2026-06-18T06:41:07+00:00

I have a user table and a user_detail table with one to one mapping

  • 0

I have a user table and a user_detail table with one to one mapping user_detail table have a field user_id to be used for this relation which stores id field value of corresponding user.

How to write the hibernate hbm file for this relation?

UPDATE

what my problem is that user’s primary key is id , user_detail’s foreign key is user_id

all the examples i got in internet users user_id as users primary key and the same as foreign key in other 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-18T06:41:09+00:00Added an answer on June 18, 2026 at 6:41 am

    For User mapping….

    <?xml version="1.0"?>
            <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
            <!-- Generated 25 April 2011 7:52:33 PM by Hibernate Tools 3.4.0.CR1 -->
            <hibernate-mapping>
                <class name="com.rais.User" table="USER" catalog="mydb">
                    <id name="userId" type="java.lang.Integer">
                        <column name="USER_ID" />
                        <generator class="identity" />
                    </id>
                    <property name="userName" type="string">
                        <column name="USER_NAME" length="10" not-null="true" unique="true" />
                    </property>
                    <property name="userCode" type="string">
                        <column name="USER_CODE" length="20" not-null="true" unique="true" />
                    </property>
                    <one-to-one name="userDetail" class="com.rais.UserDetail"
                        cascade="save-update"></one-to-one>
                </class>
            </hibernate-mapping>
    

    For UserDetail mapping.

        <?xml version="1.0"?>
        <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
        <!-- Generated 25 April 2011 7:52:33 PM by Hibernate Tools 3.4.0.CR1 -->
        <hibernate-mapping>
            <class name="com.rais.UserDetail" table="USER_DETAIL"
                catalog="mydb">
                <id name="userId" type="java.lang.Integer">
                    <column name="USER_ID" />
                    <generator class="foreign">
                        <param name="property">user</param>
                    </generator>
                </id>
                <one-to-one name="user" class="com.rais.User"
                    constrained="true"></one-to-one>
                <property name="compName" type="string">
                    <column name="COMP_NAME" length="100" not-null="true" />
                </property>
                <property name="compDesc" type="string">
                    <column name="COMP_DESC" not-null="true" />
                </property>
                <property name="remark" type="string">
                    <column name="REMARK" not-null="true" />
                </property>
            </class>
        </hibernate-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table, Messages, which is set out as follows: This table stores
This is probably a newbie question. I have a table USER which contains info
I have a User table which has a PrivilegeId foreign key points to a
I have a user table like this FIRSTNAME | LASTNAME | ID | --------------------------------
I have two tables user table user_id | name | 1 | peter |
I have a user table with and id field and 10 other fields storing
I have a user table with a level column. The level column is numeric
I have a User table that has all of their avatars saved in an
I have a user table 'users' that has fields like: id first_name last_name ...
Consider i have a user table and I have three columns mobilePhone , homePhone

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.