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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:52:02+00:00 2026-06-03T11:52:02+00:00

It’s possible I am not doing this right at all. I am initializing and

  • 0

It’s possible I am not doing this right at all.

I am initializing and storing into the session scope an object which contains details of the currently logged in user.

The CFC is called Provider, and when the user succesfully logs in I call:

session.Provider = New model.Provider().init(loginResult.ProviderID);

I have a method in the CFC called resetValues, which is to set the specified values to an empty string, but I can’t work out how to save the entity once I have reset the values.

Here is the full CFC. I am attempting to save with entitySave( this );, but not working. Any suggestions on how I should save (persist) this changes? Or do I need to completely rethink how I am going to change these values?

Many Thanks in advance.

component persistent="true" table="provider" {
property name="id" fieldtype="id" column="provider_id";
property name="title" ormtype="text";
property name="status" ormtype="integer";
property name="email" ormtype="text";

property name="ext_src" ormtype="text";
property name="ext_src_login1" ormtype="text";
property name="ext_src_login2" ormtype="text";
property name="ext_src_login3" ormtype="text";
property name="ext_src_login4" ormtype="text";

//property name="rooms" fieldtype="one-to-many" cfc="Room" fkcolumn="provider_id";

//init()
public function init(providerID="0"){
    variables.providerID = arguments.providerID;
    return this;
}

//get()
public function get(){
    return entityLoadByPK("Provider",variables.providerID);
}

//resetValues()
public function resetValues(){
    this.setExt_src_login1('');
    this.setExt_src_login2('');
    this.setExt_src_login3('');
    this.setExt_src_login4('');
    entitySave(this);
}

}

Im getting the following error: a different object with the same identifier value was already associated with the session

  • 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-03T11:52:21+00:00Added an answer on June 3, 2026 at 11:52 am

    Couple of things i see wrong with this

    1. its not advisable to store ORM entites in a scope that persists between requests, you will run into problems with detached entities (see Things to watch out for in ColdFusion 9 with CF-ORM). An ORM entity is attached to a hibernate session (not to be confused with a cf session) which does not span requests, once the requests end the entity you’ve assigned to session will become detached. Store the providerid in the session and pull the entity in each request. If that seems like too much overhead, just store the things you need for a basic request, like id and name, then only load the entity when your actually performing an operation that requires it.

    2. you shouldn’t modify a field with type of ‘id’ (unless your using provider=”assigned”).

    Inside a hibernate session only one instance of an entity with a given identifier can exist, so by setting the id of your entity and then trying to do entityLoadByPK() on the same id you’re confusing hibernate.

    If you want to have a get() method to retrieve a particular entity by id, its best to place this in a service or factory. Its easy to create an abstract service with generic methods for getting or finding entities which you can then extend with methods for your specific needs. Coldspring 2 includes an AbstractGateway which is a great starting point – http://sourceforge.net/apps/trac/coldspring/wiki/ORMAbstractGateway

    The TLDR; fix is to do

    session.provider = entityLoadByPK("Provider", loginResult.ProviderID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.