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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:51:25+00:00 2026-06-03T07:51:25+00:00

I am defining an entity, myParent, it works fine except for one thing. It

  • 0

I am defining an entity, myParent, it works fine except for one thing. It has the following defined :

@OneToMany(mappedBy = "myParent", cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private List<Child> children;

This causes a left or right join to be performed so I get two parents if there are two children. I don’t want that I just want one parent, and two children.

I could change fetchtype to lazy but I didn’t really want that … ?

when I select all parents the list contains duplicate parents, I do not want the duplicates.

  • 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-06-03T07:51:27+00:00Added an answer on June 3, 2026 at 7:51 am

    You should use the DISTINCT_ROOT_ENTITY ResultTransformer.

    This means that each row of results is a distinct instance of the root entity.

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

Sidebar

Related Questions

Defining custom components in Facelets is easy and quick but there's one thing I
I'm kinda stuck defining a Hibernate Entity: Assuming I have the following two tables
I have a Department entity which has a one-to-many relationship to an Employee entity.
I would like to write a JPA entity class that has a one to
I have an entity that is actually tree object structure (defining only relevant properties
So I was reading the following documentation on defining your own property types in
I'm using Java and JPA for ORM. Initially I was defining entity keys like
What's the benefit of defining the primary key attribute as virtual in entity Framework?
I would like a 'RolesPlayed' entity with the following columns user role department/project/group All
In the following blog: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx The blog contains the following code sample: public class

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.