Updating Primary Key of an Object

Thread is closed for posting
5 posts, 0 answers
  1. Ashok Sridhar
    Ashok Sridhar avatar
    9 posts
    Member since:
    Dec 2006

    Posted 14 Apr 2009 Link to this post

    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.
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 15 Apr 2009 Link to this post

    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.
  3. prabhu
    prabhu avatar
    6 posts
    Member since:
    Jun 2007

    Posted 16 Apr 2009 Link to this post

    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!!!!!!!!!!!!!!!!!!!
  4. Ashok Sridhar
    Ashok Sridhar avatar
    9 posts
    Member since:
    Dec 2006

    Posted 20 May 2009 Link to this post

    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)




  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 21 May 2009 Link to this post

    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.
Back to Top