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 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

Ask A Question

Stats

  • Questions 267k
  • Answers 267k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should do it. SendKeys.Send("^X") .. but SendKeys.. yuck.. :-) May 13, 2026 at 12:46 pm
  • Editorial Team
    Editorial Team added an answer Simply calling your authenticate method should trigger logic within Auth… May 13, 2026 at 12:46 pm
  • Editorial Team
    Editorial Team added an answer I know that Safari implements a webkitTransitionEnd callback that you… May 13, 2026 at 12:46 pm

Related Questions

I have an ADO .Net Entity Data Model for my database. In this Model
We are in the process of porting a legacy system to .NET, both to
I'm creating an online dictionary and I have to use three different dictionaries for
I hope I can explain this clearly. I have a table, lets call it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.