ORM mapping of timestamp

Thread is closed for posting
13 posts, 1 answers
  1. Andreas Kaech
    Andreas Kaech avatar
    121 posts
    Member since:
    Sep 2004

    Posted 15 Nov 2008 Link to this post

    Hi Telerik,
    I have problems with the timestamp type when reverse mapping.
    How to map this type?

    Best regards,
    Andreas
  2. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 18 Nov 2008 Link to this post

    Hi Andreas,

    if you are referring to T-SQL timestamp columns: this can be done with the following, yet undocumented extension in the app.config file (which you need to enter manually, the design UI has not been implemented yet):

    <class name="....">
                <extension key="db-optimistic-locking" value="backend">
                  <extension key="db-column">
                    <extension key="db-type" value="BIGINT" />
                    <extension key="db-column-name" value="vers" />
                    <extension key="db-length" value="8" />
                  </extension>
                </extension>
    </class>

    In this case, vers is the name of the version column holding the timestamp value.
    Please note, that this is not an official feature yet.

    Kind regards,
    Thomas
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mike
    Mike avatar
    7 posts
    Member since:
    Jun 2007

    Posted 12 Feb 2009 Link to this post

    Thomas, how is this done practically?  I've started with   build 2008.03.1327.2 trialling with two tables ( where my project has over 40 ) - I did this change manually and reran the Reverse Engineer.  I got a property setter for the Timestamp field?  
    Michael
  4. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 13 Feb 2009 Link to this post

    Hi Mike,

    again: Not an official feature yet, as we dont have a GUI for controlling this setting.

    OpenAccess knows about the version column. That column can be mapped to a field or not. When data is read for the first time in a transaction boundary (or written to), OpenAccess makes sure it has the value of that column. When you store your changes in Transaction.Commit, the value of this column is used and appended in the UPDATE ... WHERE clause. Where the value for the column is held during the course of the transaction? In an internal 'State' instance, so it does not matter whether the value is visible in a field or not.

    Hope this clarifies it a bit,
    Thomas
    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.
  5. Thomas
    Thomas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 24 Feb 2009 Link to this post

    Hi Telerik,

    I also have this problem with MS SQL Server timestamp fields. I am porting an application where we used this field for concurrency control, but now with OA I get the error that I am not allowed to write into this field.
    I have changed the app.config according to this post but it still will not work. Should I exclude the timestamp field from the mapping?

    Regards,
    Thomas
  6. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Feb 2009 Link to this post

    Hello Thomas,

    why are you writing to the field? The field's value is obtained from the server, and passed back uninterpreted/unaltered to the server as part of the UPDATE statement generated during Transaction.Commit(). Currently it is best to not make the column user visible, and the mapping snippet given in a previous post is working fine.

    Please note that we had a rare issue with timestamp columns in the past release, but 2008.03.1421.01 does not have the problem.

    Kind regards,
    Thomas
    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.
  7. Thomas
    Thomas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 24 Feb 2009 Link to this post

    Hello Thomas.

    The error appears when I create a new object like so:
    User u = new User();
    objectscope.Transaction.Begin();
    objectscope.Add(u);
    objectscope.Transaction.Commit();

    I have tried several ways but none worked properly. I tried setting the timestamp with null or with an empty byte array (which it seems to be). In another project I removed the timestamp fields from the classes.

    Regards
    Thomas
  8. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 26 Feb 2009 Link to this post

    Hello Thomas,

    this is strange as on my side this works exactly as I described. Please verify that such a fragment of the app.config as given ealier in this thread is used for the User class.
    Is the timestamp column in the database nullable?

    Regards,
    Thomas
    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.
  9. Thomas
    Thomas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 27 Feb 2009 Link to this post

    Hello Thomas.

    It gets even more confusing. I just reran the Reverse Mapping Tool and after are merge with the database the all the unsupported timestamp fields get recognized as OpenAccess versioning fields. Yet I did not find anything about this in the documentation.

    I know that the old Vanatec version could use a datetime column (which was called timestamp in the docs) for versioning, but was not able to make something about the SQL Server timestamp column (which really is a timestamp).

    What can I do now? Should I use the MS SQL Server timestamp column for versioning and concurrency control or should I replace this column with an int column?

    Regards,
    Thomas
  10. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 27 Feb 2009 Link to this post

    Hello Thomas,
    Just to update you we are still investigating the reason behind the error. When we have an understanding what is happening exactly and a solution for you, we will notify you asap.

    All the best,
    Dimitar Kapitanov
    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.
  11. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 27 Feb 2009 Link to this post

    Hello Thomas,

    yes, as I said : this is still an unofficial feature, where the columns are correctly detected by the reverse engineering, but you are not able yet to use the forward wizard to enter the same mapping; the runtime part is also fine, meaning that with the correct mapping (as produced by the rev-eng.) you are able to use such TIMESTAMP columns for concurrency control.
     I will ask product management to increase the priority of this feature.

    Regards,
    Thomas
  12. Mike
    Mike avatar
    7 posts
    Member since:
    Jun 2007

    Posted 13 Mar 2009 Link to this post

    Thomas,
    Any news from product management on this one?  My efforts at using class inheritance turned into a nightmare of multiple version columns.  Check out this support ticket http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=193103  .
    If the Product Manager is not accommodating please ask him/her to de-prioritise his teams activity improving LINQ and instead develop a solution for Row Versioning Concurrency Control in SQL-Server which results in the Reverse Engineer generating code the Forward Mapper understands. 
    Michael
     
  13. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 18 Mar 2009 Link to this post

    Hi Mike,
    We will definitly work on the wiazrd enhancement enhancement for the next release. Rowversion support in the reverse mapping wizard is already on the list. I hope that we can do it for one of the patches.

    Regards,
    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