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 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
  • 1 View
  • 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 have a problem that is quite simple to understand, but for me it
I have a seemingly simple problem, but I can't quite figure out a solution.
I think my problem may be quite simple, but after trying different approaches I
I guess this is a quite simple (read: very simple) question, but I have
Its quite simple thing which i am doing, i have done it before but
Im quite sure there is a very simple fix to my problem, but i
My problem seems to be quite simple, but it's not working the intuitive way.
My problem is quite simple: I have a 400MB file filled with 10,000,000 lines
This problem is probably very simple to solve but it is not clear to
We have a relatively simple assignment that I understand in theory but I think

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.