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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:26:49+00:00 2026-05-20T19:26:49+00:00

my problem is quite simple, but very important in general – I think. I

  • 0

my problem is quite simple, but very important in general – I think. I have done research for a few hours but didn’t find anything useful.

Introduction:
I have entity that is named Employee – which is central class of my system(lets say its HR Management). By writing central I have on my mind that it has many relations to other entites. There are OneToOne, OneToMany and ManyToOne properties in it.
Problem:
In some cases I have to refresh this entity(it has also basic properties like ‘String name;’ and so on) – after it was changed in one EntityManager context(hibernate Session) and has to be refreshed in other. Of course I can use for it:

entityManager.refreash(employee);

but… it also will refresh like “one hundred” related entites(mentioned: 1-1, -1, 1- relations), because those relations have annotation parameter Cascade.All or Cascade.REFREASH for them. What is not needed in that situation – I only use Employee entity itself in this context. And what is NOT WANTED because it will strike performance and even locally takes like 0.5 s…
Question:
Is there any way to refresh entity optionally “turning off” cascades on its properties. Or maybe: is there any way to refresh only specific properties of entity using Hibernate/JPA??

I really don’t want those 20 ore more long SQL queries triggered by Hibernate, when I refresh my entity in those situations, but in other situations it is wanted.

In other words, I would say that I need option like “respectCascadesOnRefresh=true/false” that can be set before refreash.

Any other ideas?

Any help appreciated,

Pedro

  • 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-20T19:26:49+00:00Added an answer on May 20, 2026 at 7:26 pm
    • Firstly, if you have only two or three fields to refresh, use criteria api.

    • Secondly, Cascade is not a good thing in absolute context – you’d better resolve some of the dependecies manually.

    • Thirdly, use FetchType.LAZY for collections!

    P.S. And NO, you can’t use cascade manually, as this annotations are used once while generating your db scheme.

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

Sidebar

Related Questions

I think my problem may be quite simple, but after trying different approaches I
I've never learnt JavaScript, but I imagine this is quite a simple problem. Just
I do not have problem as such but I am quite new to Ruby.
Today we faced a quite simple problem that were made even simpler by the
I have faced this problem quite often during the last couple of months, during
The problem is quite basic. I have a JTable showing cached data from a
I have a quite common problem, as I saw in the various user groups
Problem: I have two spreadsheets that each serve different purposes but contain one particular
My question is a very simple one i'm sure. It's just I'm not quite
Hi this question or problem i have its very hard i have search and

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.