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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:44:16+00:00 2026-05-21T03:44:16+00:00

In my UserTbl entity, I have this @OneToOne( cascade = CascadeType.REMOVE, mappedBy = user,

  • 0

In my UserTbl entity, I have this

@OneToOne( cascade = CascadeType.REMOVE, mappedBy = "user", fetch=FetchType.EAGER )
private RetailPostUserTbl retailPostUser;

@OneToOne( cascade = CascadeType.REMOVE, mappedBy = "user", fetch=FetchType.EAGER )
private BackOfficeUserTbl backOfficeUser;

But both are ALWAYS null.

A user must belong to at least one of them or both but the query always return null.

I tried fetching it via the criteria api like this

    Root<UserTbl> root = cq.from( UserTbl.class );
    root.fetch( UserTbl_.retailPostUser, JoinType.LEFT );
    root.fetch( UserTbl_.backOfficeUser, JoinType.LEFT );

But they are still always null.

Any ideas why this is not working?

The reverse works fine, for eg

in RetailPostUserTbl, this works

@OneToOne( optional = false, cascade=CascadeType.REMOVE )
@PrimaryKeyJoinColumn
private UserTbl user;
  • 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-21T03:44:16+00:00Added an answer on May 21, 2026 at 3:44 am

    You must be doing something wrong while saving or retrieving the entity, for @OneToOne mapping the FetchType is by default EAGER and you don’t have to mention it explicitly.
    Have you tried to load the entity by –

    entityManager.find();
    

    if above method works and returns the entity with all the mapped objects then check your criteria query.

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

Sidebar

Related Questions

I am facing a problem. I have created two sessions: Session[userid] = UserTbl.userid; Session[userType]
So I have the following piece of code: var structures = { loginStructure :
i have an application wherein i have incorporate a Remember Me feature for the
I have a site that requires Windows Authentication the application obtains the credential from
I have a UserBll class which has following method public string GetaspnetUserIdByUserName(string name )
I'm having trouble describing this issue, which is probably why I can't find the
I have a CustomValidator that is being used to check username availability, but it
I am working with MVC3 and using a custom ModelBinder to pass around the
is there a better way to work with ZF useing the mappers, real life
I want to trigger an update on a specifc column, when changed. (history: some

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.