This is a migrated thread and some comments may be shown as answers.

Exception on GetObjectById

3 Answers 92 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Markus
Top achievements
Rank 1
Markus asked on 19 Feb 2009, 04:11 PM
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



3 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 19 Feb 2009, 05:27 PM
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.
0
Markus
Top achievements
Rank 1
answered on 25 Feb 2009, 11:04 AM
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

0
Accepted
Jan Blessenohl
Telerik team
answered on 27 Feb 2009, 04:37 PM
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.
Tags
General Discussions
Asked by
Markus
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Markus
Top achievements
Rank 1
Share this question
or