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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:42:04+00:00 2026-06-04T18:42:04+00:00

I currently have the following (simplified) class / db schema: Entity Prospect Customer +-

  • 0

I currently have the following (simplified) class / db schema:

Entity          Prospect     Customer
 +- Id           +- Id        +- Id
 +- Address      +- Entity    +- Entity
 +- Name         +- ...       +- ...
 +- ...

ENTITY              PROSPECT           CUSTOMER
======              ==========         ========
ID - INT PK         ID - INT PK        ID - INT PK
ADDRESS - VARCHAR   ENTITY_ID - INT FK ENTITY_ID - INT FK
NAME - VARCHAR      ...
...

Along with the following fluent mapping:

PROSPECT_MAP:
Table("PROSPECT");
Id(x => x.Id).GeneratedBy.Increment();
References(x => x.Entity).Cascade.All().Fetch.Join().Column("ENTITY_ID");
...

CUSTOMER_MAP:
Table("CUSTOMER");
Id(x => x.Id).GeneratedBy.Increment();
References(x => x.Entity).Cascade.All().Fetch.Join().Column("ENTITY_ID");
...

Now there are also a bunch of stuff attached to the entity (using entity_id as a FK). In my application, a prospect can become a customer.

Hence I would like to create a new Customer, link it to the entity_id used by the ex-prospect (so that all info related to that entity now belong to the customer) and then delete the prospect from the database (so basically just remove the entry from the prospect table and not cascade down to its child components which are now linked by the newly created customer)

Is this possible with NHibernate? Note that I need the cascade.all in my ProspectMap as deleting a prospect along with its components should remain an option in the app.

Thanks a lot.

  • 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-04T18:42:06+00:00Added an answer on June 4, 2026 at 6:42 pm
    void UpgradeToCustomer(Prospect p)
    {
        var customer = new Customer
        {
            Entity = p.Entity
        };
    
        p.Entity = null; // prevent cascading
    
        session.Delete(p);
        session.Save(customer);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following (simplified) Hibernate entities: @Entity @Table(name = package) public class Package
I have the following model class (simplified) class A{ private String name; private List<B>
I currently have the following objects persisting successfully: Person first name, etc. Exams title,
I currently have the following MySQL statement to replace the HTML entity for a
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
I have the following (simplified) classes: public class Person { public string Id {get;
I have the following (simple) mapping: @Entity public class Role { @OneToMany( fetch =
Currently I have code like the following (simplified somewhat). Eventually, I've added more and
I have a Rails app with the following (simplified) models: # member.rb class Member
I currently have the following dataset (simplified): { 'component_id':1, '_locales':[ { 'url': 'dutch', 'locale':

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.