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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:18:17+00:00 2026-05-11T13:18:17+00:00

I have two related tables, MANY and ONE. An integer ONE_ID column on the

  • 0

I have two related tables, MANY and ONE. An integer ONE_ID column on the MANY table formalises a many-to-one relationship.

I want to map to Many and One domain objects and to have Hibernate generate the DDL including a foreign key constraint on MANY.ONE_ID. But I want a simple property getter and setter pair (‘int getOneId() / void setOneId(int)’) on the Many domain object rather than the association methods that Hibernate would ordinarily expect me to provide (‘One getOne() / void setOne(One)’). Is this possible?

I’ll try and explain why I want this: I actually have hundreds of such many to one associations for which I want the FK constraint but that I’ll never need to navigate. The hibernate mapping file and the domain objects are to be created by code generation. All I need to do at runtime is to be able to read the FK property from the ‘many’ side object and to set it; I never need to actually navigate the many to one association. Because of the code generation issues it would greatly simplify things if I could have simple property based accessors for the FK field.

  • 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. 2026-05-11T13:18:17+00:00Added an answer on May 11, 2026 at 1:18 pm

    AFAIK, you have two options:

    • Declare the mapping normally, and make the association lazy. This way you won’t pay for what you don’t use. You’ll also want to carefully choose the owner of the association. Addittionaly, you specify a Long property and map it to the FK.
    • Don’t rely on hibernate to generate the ddl/schema. Map the tables as you’d originally like (no association, just long types).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 related MySQL tables in a one to many relationship. Customers: cust_id,
I have two tables, that relate via a one-to-many relationship i.e tableOne (1)----------(*) tableTwo
Suppose i have two tables with one to many relationship (association in EF 4.1)
I have two related tables in my database: Page and Tag. One Page can
I have two tables related: DataEntered and Model DataEntered -currentModel Model One DataEntered can
I have two tables that are related via a mapping table: keywords titles I
The general form of a many-to-many relationship is to create three two-column tables (e.g.
I have a table, say STUDENTS, that is related one-to-many to another table, CLASSES.
I have two tables books and tags which are in a many-to-many relationship via
i have two tables both are related with primary-foreign key ralation and i have

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.