NoSuchObjectException when Inserting Entity

18 posts, 0 answers
  1. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 27 Apr 2011 Link to this post

    Hi there,

    I'm using Telerik's ORM against an Oracle database.

    When I try to insert an entity named "FormasContacto" (as shown in telerik0.png) into the DB I get the error "NoSuchObjectException... No row for...." (telerik2.png). The data is in fact inserted in the database but I don't know what to do in order to avoid such behaviour.

    Note: The image "telerik1.png" shows the way I try to add the entity. The ID of the table is generated by a sequence that exists in the database.


    Can you please help me.
  2. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 28 Apr 2011 Link to this post

    When debugging, I realized that all class fields had values except the ID. The ID is backend calculated and implemented as described in:

    http://www.telerik.com/help/openaccess-orm/openaccess-tasks-model-tools-manage-auto-incremental-columns-oracle.html

    This problem is avoiding my progress at my solution. So any help would make me very thankfull.
  3. DevCraft banner
  4. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 28 Apr 2011 Link to this post

    I forgot to set the Entity class Property "Identify Mechanism" to "DataBaseServerCalculated".

    Sorry guys...
  5. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 28 Apr 2011 Link to this post

    I forgot to set the Entity class Property "Identify Mechanism" to "DataBaseServerCalculated".

    Sorry guys...
  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 29 Apr 2011 Link to this post

    Hi Carlos,

    Such exceptions usually occur when it is not set in the OpenAccess' metadata that the identity for this class should be generated by the server and the ID member preserves its default value of 0. As it seems this was the problem in your case as well.
    We are glad that you have solved the problem by yourself, please let us know if you need further assistance.

    Regards,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 23 May 2011 Link to this post

    Hi Telerik.

    I have the same problem. Unfortunately, setting identityMechanism = "DatabaseServerCalculated" does not work for me. What am I doing wrong? 

    Thank you for your help. 

    Peter

    From log

    Telerik.OpenAccess Information: 2687 : driver.pool.alloc          7 active=1/10 idle=3/10 con=-843466865
    Telerik.OpenAccess Information: 2688 : driver.con.prepareStat     -843466865 INSERT INTO [ipoprt] ([cas], [dallas], [datum_zmeny], [ixs_ref], [ixs_ref_zmena], [terminal], [lic], [old_pruchod], [opt], [platnost], [poznamka], [pritomnost]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    select scope_identity()
    Telerik.OpenAccess Information: 2689 : driver.pspool.alloc        50 -843466865 INSERT INTO [ipoprt] ([cas], [dallas], [datum_zmeny], [ixs_ref], [ixs_ref_zmena], [terminal], [lic], [old_pruchod], [opt], [platnost], [poznamka], [pritomnost]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    select scope_identity()
    Telerik.OpenAccess Information: 2690 : driver.stat.exec           -843466865 INSERT INTO [ipoprt] ([cas], [dallas], [datum_zmeny], [ixs_ref], [ixs_ref_zmena], [terminal], [lic], [old_pruchod], [opt], [platnost], [poznamka], [pritomnost]) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11)
    select scope_identity() [@p0=2011-01-01T18:41:00.0000000 @p1=DBNull @p2=2011-05-23T13:19:32.9974709+02:00 @p3="sa  X:Z>YT18" @p4="TEST        " @p5=-1 @p6=DBNull @p7=DBNull @p8=DBNull @p9=1 @p10=DBNull @p11=2]
    Telerik.OpenAccess Information: 2691 : driver.stat.close          -843466865 
    Telerik.OpenAccess Information: 2692 : driver.con.commit          -843466865 
    Telerik.OpenAccess Information: 2693 : driver.con.rollback        -843466865 
    Telerik.OpenAccess Information: 2694 : driver.pool.release        7 active=0/10 idle=4/10 con=-843466865
    Telerik.OpenAccess Information: 2695 : cache.evict.oids           1
    Telerik.OpenAccess Information: 2696 : cache.evict.oids           1
    Telerik.OpenAccess Information: 2697 : sm.begin                   7 optimistic
    Telerik.OpenAccess Information: 2698 : sm.fetch                   WebTime11.Web.PassesApp.IPOPRT 0 [default] _CAS 0 state(s)
    Telerik.OpenAccess Information: 2699 : driver.pool.alloc          7 active=1/10 idle=3/10 con=-843532401
    Telerik.OpenAccess Information: 2700 : driver.con.prepareStat     -843532401 SELECT [cas] AS COL1, [dallas] AS COL2, [datum_zmeny] AS COL3, [ixs_ref] AS COL4, [ixs_ref_zmena] AS COL5, [lic] AS COL6, [old_pruchod] AS COL7, [opt] AS COL8, [platnost] AS COL9, [poznamka] AS COL10, [pritomnost] AS COL11, [terminal] AS COL12 FROM [ipoprt] WHERE [por_cislo] = ?                       
    Telerik.OpenAccess Information: 2701 : driver.pspool.alloc        49 -843532401 SELECT [cas] AS COL1, [dallas] AS COL2, [datum_zmeny] AS COL3, [ixs_ref] AS COL4, [ixs_ref_zmena] AS COL5, [lic] AS COL6, [old_pruchod] AS COL7, [opt] AS COL8, [platnost] AS COL9, [poznamka] AS COL10, [pritomnost] AS COL11, [terminal] AS COL12 FROM [ipoprt] WHERE [por_cislo] = ?                       
    Telerik.OpenAccess Information: 2702 : driver.stat.execQuery      -843532401 SELECT [cas] AS COL1, [dallas] AS COL2, [datum_zmeny] AS COL3, [ixs_ref] AS COL4, [ixs_ref_zmena] AS COL5, [lic] AS COL6, [old_pruchod] AS COL7, [opt] AS COL8, [platnost] AS COL9, [poznamka] AS COL10, [pritomnost] AS COL11, [terminal] AS COL12 FROM [ipoprt] WHERE [por_cislo] = @p0                        [@p0=0]
    Telerik.OpenAccess Information: 2703 : driver.rs.next
    Telerik.OpenAccess Information: 2704 : driver.rs.close
    Telerik.OpenAccess Information: 2705 : driver.pspool.release      49 -843532401 SELECT [cas] AS COL1, [dallas] AS COL2, [datum_zmeny] AS COL3, [ixs_ref] AS COL4, [ixs_ref_zmena] AS COL5, [lic] AS COL6, [old_pruchod] AS COL7, [opt] AS COL8, [platnost] AS COL9, [poznamka] AS COL10, [pritomnost] AS COL11, [terminal] AS COL12 FROM [ipoprt] WHERE [por_cislo] = ?                       
    Telerik.OpenAccess Information: 2706 : driver.con.commit          -843532401 
    Telerik.OpenAccess Information: 2707 : driver.con.rollback        -843532401 
    Telerik.OpenAccess Information: 2708 : driver.pool.release        7 active=0/10 idle=4/10 con=-843532401
    A first chance exception of type 'Telerik.OpenAccess.Exceptions.NoSuchObjectException' occurred in Telerik.OpenAccess.dll
    'iexplore.exe' (Silverlight): Loaded 'C:\Program Files\Microsoft Silverlight\4.0.50826.0\en-US\mscorlib.debug.resources.dll'

    From rlinq

    ....
      
    <DomainClass Id="cfaeedd3-21d6-431b-8a83-c573a1ff28b7" name="IPOPRT" namespace="WebTime11.Web.PassesApp" showPropertiesCompartment="true" identityMechanism="DatabaseServerCalculated" showNavigationCompartment="true" showImplementationCompartment="true">
     <Property Id="5e7377e6-13f1-4ba2-9904-b8aea0faf6be" name="POR_CISLO" type="Int32" label="POR_CISLO : Int32" kind="Persistent" identity="true" fieldName="_POR_CISLO" />
      
    ....
      
    <orm:class name="IPOPRT" uniqueId="cfaeedd3-21d6-431b-8a83-c573a1ff28b7">
     <orm:table name="ipoprt" />
     <orm:identity>
     <orm:key-generator name="autoinc" />
     <orm:single-field field-name="_POR_CISLO" />
     </orm:identity>
      
    ....
      
    <orm:field name="_POR_CISLO" property="POR_CISLO" uniqueId="5e7377e6-13f1-4ba2-9904-b8aea0faf6be" type="System.Int32">
     <orm:column name="por_cislo" sql-type="int" nullable="false" length="0" scale="0" primary-key="true" backend-calculated="true" ado-type="Int32" />
    </orm:field>
      
    ....

  8. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 26 May 2011 Link to this post

    Hello Petr Šatka,

    It seems the backend calculated option is set correctly in the model, as the generated SQL is not trying to insert any value for the primary key column, but the server is not setting it either.
    Could you please show us the table definition (in SQL) and the code that you are executing to insert an object of this type? I hope this will help us to reproduce the problem and find a solution. It would also be helpful if you can clarify which database server you are using.

    Greetings,
    Alexander
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  9. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 27 May 2011 Link to this post

    Hello Alexander.

    There is the table definition:
    create table dbo.ipoprt (
       lic                  char(4)              null,
       poznamka             varchar(255)         null,
       old_pruchod          int                  null,
       datum_zmeny          datetime             null,
       ixs_ref              char(12)             not null,
       cas                  datetime             not null,
       platnost             int                  not null,
       pritomnost           smallint             not null,
       terminal             smallint             not null,
       ixs_ref_zmena        char(12)             null,
       por_cislo            int                  not null default 0,
       opt                  int                  null,
       dallas               int                  null,
       constraint pk_ipoprt primary key  (por_cislo)
    )
     
    create trigger dbo.tia_por_ipoprt on dbo.ipoprt instead of insert as
    begin
      declare 
        @numrows    int,
        @numnull    int,
        @errno      int,
        @errmsg     varchar(255),
        @por_cislo      int
     
         
        select  @numrows = @@rowcount
            if @numrows = 0
                return
    --pokud je por_cislo jiz zadano, nemen je           
        select @por_cislo = por_cislo from inserted
            if @por_cislo > 0
            begin
                insert into ipoprt (ixs_ref, cas, platnost, pritomnost, lic, terminal, ixs_ref_zmena, por_cislo, poznamka, old_pruchod, datum_zmeny, opt, dallas )
                select ixs_ref, cas, platnost, pritomnost, lic, terminal, ixs_ref_zmena, por_cislo, poznamka, old_pruchod, datum_zmeny, opt, dallas from inserted
                return
            end
                 
    --kod trigeru
        select @por_cislo = max(por_cislo) from ipoprt
        if @por_cislo is null
           select @por_cislo = 0
        select @por_cislo = @por_cislo + 1
        -- aktualizuj poradove cislo
        --update ipoprt set por_cislo = @por_cislo where ipoprt.por_cislo=0
        insert into ipoprt (ixs_ref, cas, platnost, pritomnost, lic, terminal, ixs_ref_zmena, por_cislo, poznamka, old_pruchod, datum_zmeny, opt, dallas )
        select ixs_ref, cas, platnost, pritomnost, lic, terminal, ixs_ref_zmena, @por_cislo, poznamka, old_pruchod, datum_zmeny, opt, dallas from inserted
         
    return
     
    /*  errors handling  */
    error:
        raiserror @errno @errmsg
        rollback  transaction
    end

    There is the code samle:
    ds.IPOPRTs.Add(new IPOPRT() {CAS = DateTime.Now, IXS_REF="TEST        ", OLD_PRUCHOD = 1988436026, PLATNOST = 1, PRITOMNOST = 0, TERMINAL = -1});
    ds.SubmitChanges();

    Database server is:
    Microsoft SQL Server Standard Edition (64-bit)
    10.0.2531.0

    I think, the problem is table definition, especially "default 0". Unfortunately I can not make changes in the table definition because of a backward compatibility.

    Regards,
    Peter
  10. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 31 May 2011 Link to this post

    Hi Petr Šatka,

    I created a domain class from your table but inserts seem to be working fine with both the "Default" and "BackendServerCalculated" identity mechanisms. However, I am testing the insert operation only with Ipoprt objects. The behavior might be different if this class has relations to other classes and you are trying to insert a graph of objects.
    Would you please send me the definitions of the tables related to ipoprt along with their foreign key constraints, if there are any? I hope this will help me to reproduce the problem.

    Kind regards,
    Alexander
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  11. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 01 Jun 2011 Link to this post

    Hi Alexander

    I do not think the problem is with a relations. I tried it with the clean database containing only the ipoprt table and trigger. I made the sample solution. Support ticket ID is: 430037

    Regards
    Peter
  12. Myth
    Myth avatar
    54 posts
    Member since:
    Jan 2010

    Posted 12 Jan 2012 Link to this post

    I have the same problem with the the latest edition of telerik OpenAccess, using fluent mapping API. The collection and property have "IsManaged()" set in both directions.

    I have "Orders" and "OrderParts". When linking new orderparts to a new order (Doesn't matter if i link it through the collection of the order object, or the object property in the orderpart), i get the exception. The identity mechanism of both is set to HighLow.
  13. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 16 Jan 2012 Link to this post

    Hello Myth,

    Are you using RIA Services? Petr's problem was caused by a bug in our RIA Services provider, which does not return to the client the identity of the newly inserted object. However, the objects are successfully inserted into the database. If this is not the case, please let us know so we can continue investigating the error.

    Regards,
    Alexander
    the Telerik team

    SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

  14. Myth
    Myth avatar
    54 posts
    Member since:
    Jan 2010

    Posted 19 Jan 2012 Link to this post

    Hello Alexander,

    I do not use RIA services. It's a normal windows application. The objects are also inserted correctly, but i do keep getting the exception message.
  15. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Jan 2012 Link to this post

    Hi Myth,

    I believe these are potentially two issues here.
    One deals with the fact that the server generated value is not obtainable by the client, hence the client is not using it. I think this is visible when looking at the trigger code as given previously. Please make sure that a trigger sets the @@identity variable, because that value will be obtained by our code for the server generated value.
    The other issue seems to be related to managed collections, but -according to your description- do not seem to use server side generated values. Can you provide us with a small reproduction of the issue? We do have tests for managed collections, but they do not indicate such a behavior.

    All the best,
    Thomas
    the Telerik team

    SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

  16. Gaurav
    Gaurav avatar
    10 posts
    Member since:
    Feb 2012

    Posted 16 Mar 2012 Link to this post

    have you resolved this issue ?
    because here i have same issue with insertion of parent child data through telerik open access orm entity model.
    we have used wcf ria domain service to communicate with it.

    Gaurav Shah
  17. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 20 Mar 2012 Link to this post

    Hello Gaurav,

    Unfortunately this problem has not been fixed yet. We will try to fix it for one of the following releases.

    Kind regards,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  18. Gaurav
    Gaurav avatar
    10 posts
    Member since:
    Feb 2012

    Posted 21 Mar 2012 Link to this post

    okie...
    now is it posible that after insetion that primary key value to be reflected in to that new created entity object.

    like
    entities.add(newobject).
    in wich newobject have 1 primary key with identity column.
    but currently primary key value shows 0 after insertion.
  19. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 22 Mar 2012 Link to this post

    Hi Gaurav,

    This should work on the server side - once you add an object to the context and commit the transaction (call SaveChanges) the identity of the inserted object is refreshed with the newly created value. However, the problem discussed in this thread is exactly that this value is not sent back to the client when a RIA service is used.

    All the best,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Back to Top
DevCraft banner