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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:07:48+00:00 2026-05-21T20:07:48+00:00

When I do a relation one to one with to entities, JPA use the

  • 0

When I do a relation one to one with to entities, JPA use the id to register the target ; but I should want an other column. How is possible ?

For instance I have two entities :

@Entity
public class Target
{
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private String id;

  @Column(unique=true, nullable=false)
  private String code;

 // and so on 
}

That’s make a table with columns ID and CODE.

A second entity with a link to Coder :

@Entity
public class ToTarget
{
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private String id;

 private Target targeted;

 // and so on 
}

That’s make a table with column ID and TARGET_ID. In TARGET_ID I have some id from column ID in table Target.

All is good, but I should want, in TARGET_ID, some code value from table Coder. How is it possible ?

Thanks.

  • 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-05-21T20:07:49+00:00Added an answer on May 21, 2026 at 8:07 pm

    Use the referencedColumnName attribute of the @JoinColumn annotation. I’m not sure this is supported by the standard though. It might work in some implementations, and not in others.

    See http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html#entity-mapping-association for Hibernate, and http://openjpa.apache.org/builds/2.1.0/apache-openjpa-2.1.0/docs/manual/manual.html#ref_guide_mapping_notes_nonstdjoins for OpenJPA.

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

Sidebar

Related Questions

Lets say I have two tables - child and parent with many-to-one relation. What
I have two models: Person and Relation. The second one stores information about relations
How would you represent a temporal many-to-many relation in SQL? Under non-temporal circumstances one
I have a relation mapping table like this: attributeid bigint productid bigint To clean
when i have a many-to.many relation with nhibernate and let nhibernate generate my db
One-to-one relations within nhibernate can be lazyloaded either false or proxy. I was wondering
In relation to this question on Using OpenGL extensions , what's the purpose of
In relation to another question , how do you account for paths that may
This is in relation to this question I am hosting this WCF service in
How can I set parent-child relation on same table? Id int, title string, ParentId

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.