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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:24:46+00:00 2026-05-14T07:24:46+00:00

Collection.clear() will delete children whenever Session flushes. What about OneToOne? Setting to null is

  • 0

Collection.clear() will delete children whenever Session flushes.

What about OneToOne? Setting to null is not a correct way. No clear() method for OneToOne exists.

Table_A has a column (not its PK!) that OneToOne references Table_B.

I wonder if Hib works as expected in my case?

My Cascading options are set to “all,delete-orphan”.

Table_A @OneToOne Table_B

Table_B @OneToMany Table_C

Now it looks like Table_A . getTable_B . getTable_C_Collection()

Suppose there are elements in Table_C collection.

What I expect from Hibernate: if I set Table_B link to null, then

all Table_C collection elements MUST BE DELETED.

It does not happen. They become ORPHANED !

  • 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-14T07:24:47+00:00Added an answer on May 14, 2026 at 7:24 am

    Hibernate’s support for cascading actions can be a bit quirky at times. If you find that you cannot get the desired behavior out-of-the-box, you can implement a Hibernate Interceptor or a Hibernate event listener. It’s actually pretty easy to do ether, and the effort is worth it (your main code remains clean).

    In this case, you probably want to implement a PostUpdateEventListener, or a PreUpdateEventListener.

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

Sidebar

Related Questions

Hibernate is not deleting orphans when I set the collection to null, although orphans
I am trying to find a way to know about garbage collection. Either, when
Is there a way to force the flash garbage collector to clean up freed
The collection of fonts available to a web developer is depressingly limited. I remember
I have a collection of objects to which I'd like to just add a
I have a collection of classes that inherit from an abstract class I created.
I'm designing this collection of classes and abstract (MustInherit) classes… This is the database
If I have a collection of database tables (in an Access file, for example)
I've got a collection that implements an interface that extends both IList<T> and List.
Suppose I have a collection (be it an array, generic List, or whatever is

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.