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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:56+00:00 2026-05-31T05:11:56+00:00

I load a Contact-objekt from the database. The Object Contact has a one-to-many mapping

  • 0

I load a Contact-objekt from the database. The Object Contact has a one-to-many mapping to ContactSecurity:

    <set name="ContactSecuritys" lazy="true" inverse="true" cascade="none" >
        <key>
            <column name="ContactId"/>
        </key>
        <one-to-many class="ContactSecurity"/>
    </set>

Now, I try to do:

contact.ContactSecuritys.Add(new ContactSecurity(Guid.NewGuid()));
Session.Merge(contact);

But this is throwing an TransientObjectExcpeption ‘object is an unsaved transient instance – save the transient instance before merging: Prayon.Entities.ContactSecurity’

I have also tried

contact.ContactSecuritys.Add(new ContactSecurity(Guid.NewGuid()) {Contact = contact});
Session.Merge(contact);

What I am doing wrong? – Does I have to extra-save the new ContactSecurity-Object with referenced Contact before merging the contact? – Or is there a simpler way to do this?

Thanks for any help.

  • 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-31T05:11:56+00:00Added an answer on May 31, 2026 at 5:11 am

    I think it because “ContactSecurity” is a new transient object. If an entity with the same identifier has already been persisted, you can use “session.Merge()”, but there is no any entity with a such identifier. You may use “session.Persist(ContactSecurity)” to attach a transient object to a Session.

    var contactSecurity = new ContactSecurity(Guid.NewGuid());
    Session.Persist(contactSecurity);
    
    contact.ContactSecuritys.Add(contactSecurity);
    Session.Merge(contact);
    

    In general I don’t understand why are you using “session.Merge()”.
    If entity “contact” is a persistent object you can use “session.Flush()” in the end of transaction, and don’t call “session.Merge()”:

    var contactSecurity = new ContactSecurity(Guid.NewGuid());
    Session.Persist(contactSecurity);
    contact.ContactSecuritys.Add(contactSecurity);
    Session.Flush();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

load() just returns a proxy by default and database won’t be hit until the
ViewA load some data from Coredata, then push to the next viewB . In
I load a form and dynamically populate a select via AJAX from a PHP
I'm using the load method to replace the contents of ONE div. $( '#ajax_tbody_result'
I fetch a json object from the server and populate my view. I then
I can't add name and image from Facebook contacts to SqLite, becouse adding is
In have a controller class that handle a Contact object. In this controller I
On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });
I load content via Ajax and then I'll have element like $('.my_content_class') and I
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();

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.