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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:12:56+00:00 2026-06-06T17:12:56+00:00

structure: TypeA has collection of TypeB and TypeB has collection of TypeC. TypeB and

  • 0

structure:
TypeA has collection of TypeB and TypeB has collection of TypeC.

TypeB and TypeC are manytomany.

TypeA mapped

HasMany<TypeB>(t => t.TypeBList).CascadeAll().Inverse()..

TypeB mapped

HasManyToMany<TypeC>(t => t.TypeCList).Casecade.All().Inverse()..

TypeC mapped

HasManyToMany<TypeB>(t => t.TypeBList).Casecade.None()...

TypeB has a method to

Add(TypeC typec) { typec.TypeBList.Add(this); TypeBList.Add(typec); }

And I need to add a new typec to typeb collection, but
I want to save by calling repo.Save(typeA) but I’m getting shared collection issue because TypeB exists in both TypeA and TypeC.

var typec = new TypeC { TypeBList = typea.TypeBList, .... }
typea.TypeBList[0].Add(typec);
repo.save(typea);

Will this not work by saving typea, am I forced to get a typeb and make the changes there?

  • 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-06T17:12:58+00:00Added an answer on June 6, 2026 at 5:12 pm

    collections on objects should generally not be shared at all and most of the time, especially when using NHibernate, you shouldn’t even alter the collection instance. better copy the contents.

    obj1.ListA.Clear();
    
    foreach(var item in obj2.ListA)
        obj1.ListA.Add(Item);
    

    Update: Why?

    Because NHibernate replaces the collection instances with own collection classes to enable lazyloading and changetracking.

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

Sidebar

Related Questions

I have this type of structure <ul> <li>one</li> <li> two has children <ul> <li>a</li>
The type of each member of the structure usually has a default alignment i.e.each
I have 2 classes with this structure: class ClassA { String typeA; List<String> valuesA;
i have function, which has to accept two types of data - Observable collection
I'm trying to build a TreeView in WPF that has categories. Basically the structure
My directory structure is as follows: /WorkingDirectory MyCollection.java /au/edu/au /UserInterface UserInterface.java /Collection Album.java CDAlbum.java
I am using EclipseLink MOXy and have a data structure that has child elements
Is there an R type equivalent to the Matlab structure type? I have a
I have a pointer of a structure type that I made. On program start
I am aware about the concepts of data type or structure alignment, packing, padding

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.