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

The Archive Base Latest Questions

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

I need a link between two entities, so I use a one-to-one @Entity @Table(name

  • 0

I need a link between two entities, so I use a one-to-one

@Entity
@Table(name = "T_USER")
public class User implements Serializable {

    @Id
    @Column(name = "user_id")
    private int userId;

    @Column(name = "login")
    private String login;

    @OneToOne(optional = true)    
    @JoinColumn(name="login", referencedColumnName="person_id", nullable = true, insertable = false, updatable = false)
    private Person person;
}

@Entity
@Table(name = "T_PERSON")
public class Person implements Serializable {
    @Id
    @Column(name = "person_id")
    private String personId;

    @Column(name = "pin")
    private String pin;
}

If there is no item for a particulary PERSON in table T_USER, user.getPerson throw a exception:

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [packagename.com.entity.Person#scabriou]

But If I have reference between the 2 tables in the db, the getter works!

  • 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-28T13:46:19+00:00Added an answer on May 28, 2026 at 1:46 pm

    I can’t say if this the best solution but you could use the @NotFound annotation. E.g.

    @NotFound(action = NotFoundAction.IGNORE)
    private Person person;
    

    I believe person will remain null and the exception will not be thrown.

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

Sidebar

Related Questions

I have 2 databases and I need to link information between two big tables
I need to return data from two tables - one table contains records on
I have two PHP files that I need to link. How can I link
i want something like this the user enter a website link i need check
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this
In my Rails app I have a fairly standard has_many relationship between two entities.
As I understand it, once I've set up an RMI communications link between two
How to pass variable between two functions in same controller? Do I need to
I have two tables User and UserRole which are they connected using a link
I've got a web site that allows the user to switch between two different

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.