OrmEntityOutOfSyncException question

Posts   
 
    
IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 15-May-2006 20:58:41   
  1. I am getting "SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException} occurred", when I am trying to fetch the persisted information multiple times.
  2. I am getting "During a recursive save action an entity's save action failed. The entity which failed is enclosed." when I am trying to update the retrieved entity.

I have a JobQueueEntity and it has related entities JobAffectedEntity (similar to Customer and Orders for the customer).

JobQueueEntity maintains a Guid, 3 ints and a byte array (image type);

I am able to persist the job information successfully using:


using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConfigurationSettings.AppSettings["connString"],true))
{
    // Get the affected entities from the Job
     ArrayList affectedEntities = job.GetAffectedEntities();
    JobQueueEntity jobQueueEntity = new JobQueueEntity();
    jobQueueEntity.JobId = job.JobID;               
    jobQueueEntity.JobStatusNumber = (byte)job.State;
    jobQueueEntity.JobTypeNumber = 0;
    jobQueueEntity.OperationModeNumber = 0;     
    jobQueueEntity.JobObject = SerializeJob(job);
    // Add the job to the database
    bool saveResult = dataAccessAdapter.SaveEntity(jobQueueEntity, true);
    EntityCollection jobAffectedEntityCollection = new EntityCollection();
    foreach(AffectedEntity affectedEntity in affectedEntities)
   {
      if ((affectedEntity.AffectedEntityType == AffectedEntityType.Statement) ||    (affectedEntity.AffectedEntityType == AffectedEntityType.Page))
      {
    // TODO: Add entities to collections
    JobAffectedEntityEntity item = new JobAffectedEntityEntity();
    item.JobId = job.JobID;
    item.DataOperationNumber = (byte)job.JobOperation;
    switch(affectedEntity.AffectedEntityType)
    {
       case AffectedEntityType.Statement:                       item.StatementId = (affectedEntity as AffectedStatement).StatementId;
    break;
    case AffectedEntityType.Page                            item.StatementId = (affectedEntity as AffectedPage).StatementId;            item.PageId = (affectedEntity as AffectedPage).PageId;
    break;
    }
      }
   }
  int retCode = dataAccessAdapter.SaveEntityCollection(jobAffectedEntityCollection);
}

After saving the JobQueueEntity, I am trying to read the persisted information using the following:


JobQueueEntity jobQueueEntity;          
// Create the data acess adapter object.        
using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConfigurationSettings.AppSettings["connString"],true))
{
    jobQueueEntity = new JobQueueEntity(jobId);
    bool retcode = dataAccessAdapter.FetchEntity(jobQueueEntity);           
}

I am able to read the persisted JobQueueEntity once and I am getting the following error for subsequent fetches:

<error: an exception of type: {SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException} occurred>

Before trying to read second time, JobQueueEntity information is present in the database and after getting the above error, I don't see the JobQueueEntity information in the database and the returned code is false.

  1. When I am trying to update the JobQueueEntiy after fetching the JobQueueEntity first time and I am getting the following error:

{"During a recursive save action an entity's save action failed. The entity which failed is enclosed." }


 JobQueueEntity jobQueueEntity;         
                
using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConfigurationSettings.AppSettings["connString"],true))
{
   // Read the Job's existing record
   jobQueueEntity = new JobQueueEntity(job.JobID);
   bool retcode = dataAccessAdapter.FetchEntity(jobQueueEntity);
   if (jobQueueEntity != null)
  {
      // TODO: Update field values
      jobQueueEntity.JobStatusNumber = (byte)job.State;
     // Serialize the job
     jobQueueEntity.JobObject = SerializeJob(job);
     // Save the updated job record
     dataAccessAdapter.SaveEntity(jobQueueEntity);
   }
}

I could not update the persisted information and I could not fetch the persisted information more than once.

I am using SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll. version 1.0.2004.2 August 5, 2004

Could you tell me whether I am missing anything?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-May-2006 15:00:25   

I am able to read the persisted JobQueueEntity once and I am getting the following error for subsequent fetches:

I don't know how the subsequent fetches looks like, please provide the code for that. Most probably there is no Entity being fetched from the database, due to a non valid filter/PK. (not available in the database)

bool retcode = dataAccessAdapter.FetchEntity(jobQueueEntity);
if (jobQueueEntity != null) // change this to test for the retcode
{}

IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 16-May-2006 15:37:39   

Thanks Walaa, I am using the same code that fetches entity first time.


JobQueueEntity jobQueueEntity;          
// Create the data acess adapter object.        
using(DataAccessAdapter dataAccessAdapter = new DataAccessAdapter(ConfigurationSettings.AppSettings["connString"],true))
{
    jobQueueEntity = new JobQueueEntity(jobId);
    bool retcode = dataAccessAdapter.FetchEntity(jobQueueEntity);           
}

Before trying to fetch second time, I did make sure that the entity is present in the database.

Am I misssing anything?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 17-May-2006 03:06:10   

This does seem to be odd behavior, the changelog does not go back as far as the version you are using so I can't tell if an update has fixed this as a possible error. I would suggest that you at least try the most recent version of 1.0.2004.2 and possibly 1.0.2005.1 if you are able too.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 17-May-2006 09:25:24   

Indeed, please download the latest 1.0.2004.2 builds from the customer area, as your version is very outdated.

Frans Bouma | Lead developer LLBLGen Pro
IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 17-May-2006 15:02:16   

I was able to figure out the issue by enabling tracing. Tracing is very good feature!

Thanks for your responses.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-May-2006 15:21:30   

So what was it all about? simple_smile

It may help us and/or other users who may face the same problem.

Thanks for your feedback.

IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 17-May-2006 17:52:05   

By enabling tracing, llblgen logged database transactions and I have noticed deletion of job entity by a background thread from the application.

After deletion of this entity, when I am trying to fetch the entity, I am getting "ORMEntityOutOfSyncException" and returned code is false. [ Because there is no entity to be fetched]

Thanks for your prompt responses.

IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 18-May-2006 22:43:16   

Otis wrote:

Indeed, please download the latest 1.0.2004.2 builds from the customer area, as your version is very outdated.

Sorry that should be August 5, 2005

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 19-May-2006 09:24:31   

There's still a later build available simple_smile

Frans Bouma | Lead developer LLBLGen Pro