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

Updating Primary Key of an Object

4 Answers 175 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.
Ashok Sridhar
Top achievements
Rank 1
Ashok Sridhar asked on 14 Apr 2009, 10:33 PM
Hi,

Is it possible to update the primary key of an object.  My Scenario is:

Employer Id
Employer Name

where Name is the Primary Key and Id is the alternate key.  My business rules require that Name can be changed provided that its unique in the database (Primary Key obviously makes sure of that).  When I tried changing the name, OpenAccess threw an error.  Am I doing something wrong or is this not possible at all.

4 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 15 Apr 2009, 03:30 PM
Hello Ashok Sridhar,

Could you provide some more information so we can evaluate the problem, please? Are you using forward or reverse mapping? What identity generation mechanism do you use and what is the exception that you experienced?

Greetings,
Alexander
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
prabhu
Top achievements
Rank 1
answered on 16 Apr 2009, 05:05 PM
hi Ashok,


is it possible ashok ..,

choose Reverse mapping option in openacces

In top left corner select the   Merge schema changes with existing settings option  ,

click that option Reload u r schema merge

it wil show wat r field to be changed in database

click merge option it wil be update u r fields ,

i think it is an easy way!!!!1

otherwise one more option is there

click Reverse mapping option and choose Advanced view tab

select u r tables ->choose some field (default show primarykey) u check it ...

and generete and save config it wil update in the reverse mapping

bye!!!!!!!!!!!!!!!!!!!
0
Ashok Sridhar
Top achievements
Rank 1
answered on 20 May 2009, 10:20 PM
Hi Alexander,

I'm using Reverse Mapping.  My table does not have an identity field (or autogenerated column).  It has a combination of 3 columns as primary key.  1 of which is a foreign key id and 2 dates.  I need to be able to change one of the dates.  OA throws error when I'm trying to do so.

Here is the error message:

Unsupported Operation: Change of identity is not supported

and this is the stack trace:

at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
  at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
  at OpenAccessRuntime.DataObjects.PCStateMan.handleException(Exception x)
  at OpenAccessRuntime.DataObjects.PCStateMan.setObjectFieldImp(PersistenceCapable _pc, FieldMetaData fmd, Object currentValue, Object newValue)
  at OpenAccessRuntime.DataObjects.PCStateMan.setObjectField(PersistenceCapable _pc, Int32 field, Object currentValue, Object newValue)




0
Alexander
Telerik team
answered on 21 May 2009, 08:24 AM
Hi Ashok Sridhar,

I am afraid this is not possible. If you want to update such column you will have not to include it in the primary key.

Best wishes,
Alexander
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
Ashok Sridhar
Top achievements
Rank 1
Answers by
Alexander
Telerik team
prabhu
Top achievements
Rank 1
Ashok Sridhar
Top achievements
Rank 1
Share this question
or