Exception on GetObjectById

Thread is closed for posting
4 posts, 1 answers
  1. Markus
    Markus avatar
    43 posts
    Member since:
    Sep 2008

    Posted 19 Feb 2009 Link to this post

    Since I updated OpenAccess to version 2008.3 I get an exception on first call of GetObjectById

               Telerik.OpenAccess.IObjectScope scope = ObjectScopeProvider1.ObjectScope();
                scope.Transaction.Begin();

                int classId = scope.Database.GetClassId(typeof(Model.Material));
                string idString = String.Format("{0}-{1}", classId.ToString(), checkOutBasketItem.Id);

                Telerik.OpenAccess.IObjectId id = Telerik.OpenAccess.Database.OID.ParseObjectId(typeof(Model.Material), idString);

                material = scope.GetObjectById(id) as Model.Material;

                scope.Transaction.Rollback();

    Material is a base class and id is from an object of subclass type

    Exception details:

    Telerik.OpenAccess.OpenAccessException was unhandled
      Message="Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."
      Source="Telerik.OpenAccess"
      CanRetry=false
      StackTrace:
           bei Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
           bei Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
           bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
           bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.getObjectById(Object oid, Boolean validate)
           bei OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.getObjectById(Object o, Boolean b)
           bei Telerik.OpenAccess.RT.ObjectScope.GetObjectById(IObjectId oid)
    ....

    Inner Exception:

    "   bei OpenAccessRuntime.DataObjects.PCStateMan.setLoadRequired()\r\n   bei OpenAccessRuntime.DataObjects.PCStateMan.init(OID noid, ClassMetaData cmd, State aState, OpenAccessPersistenceManagerImp rpm)\r\n   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.reManage(OID oid, State state)\r\n   bei OpenAccessRuntime.DataObjects.LocalPMCache.addState(OID key, State value_Renamed, Boolean manage, PCStateMan[] addSm)\r\n   bei OpenAccessRuntime.DataObjects.LocalPMCache.add(OID oid, State state, PCStateMan[] sms)\r\n   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.addAndReturnFirstDirect(StatesReturned container)\r\n   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.getStateMan(OID aOID, FetchPlanIF fPlan, FieldMetaData fmd)\r\n   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.getObjectById(Object oid, Boolean validate)"

    Any idea ?
    Thanks in advance, Markus



  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 19 Feb 2009 Link to this post

    Hello Markus,
    That did never work because we try to generate a Material object as result of GetObjectById, this can lead to a undefined beahavior. You have to use the right type!

    Sincerely yours,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Markus
    Markus avatar
    43 posts
    Member since:
    Sep 2008

    Posted 25 Feb 2009 Link to this post

    Thanks for your answer, Jan. But in m opinion you could get the right type by class id. The class id defines the correct class type of the object to create. It would be nice if I could call GetObjectById with base class type and only object id as parameter. The concret class type could be determined by class id of selected record.

    Btw. I resolved the problem by using a SqlQuery and passing id as parameter.

    Best regards,

    Markus

  4. Answer
    Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 27 Feb 2009 Link to this post

    Hello Markus,
    You are right, we can do that but because of our optimization it is far better to know the real type beforehand. The restriction is there by reason to not break our optimizations and I would like to keep it as it is.

    Greetings,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top