Generated "INSERT INTO" is missing association column

9 posts, 0 answers
  1. Benoit
    Benoit avatar
    2 posts
    Member since:
    Apr 2016

    Posted 22 Sep 2016 Link to this post

    Hello,

     

    I have the following 2 classes defined in the designer:

    (EdScormPreset has a one-to-many association with ScormPackagePropertiesPreset on 2 columns)

     

     <orm:class name="EdScormPreset" behavior="readwrite" uniqueId="cee8a217-cc5d-43b0-a2af-3c8a4ebfa47e">
            <orm:table name="EdScormPreset" />
            <orm:identity>
              <orm:single-field field-name="edScormPresetNo" />
            </orm:identity>
            <orm:concurrency strategy="changed" />
            <orm:field name="edScormPresetNo" property="EdScormPresetNo" behavior="readwrite" uniqueId="6f79925b-c899-470a-a373-5ae7be139024" type="System.Int32">
              <orm:column name="EdScormPresetNo" sql-type="int" nullable="false" length="0" scale="0" primary-key="true" ado-type="Int32" />
            </orm:field>
            <orm:field name="crtnTS" property="CrtnTS" behavior="readwrite" uniqueId="0d51b2b0-87f3-4730-b6b9-d4fa517c5c43" type="System.DateTime">
              <orm:column name="CrtnTS" sql-type="datetime" nullable="false" length="0" scale="0" ado-type="DateTime" />
            </orm:field>
            <orm:field name="id" property="Id" behavior="readwrite" uniqueId="09af0d63-a98b-4aa9-9db5-41ff087a40c4" type="System.String">
              <orm:column name="Id" sql-type="nvarchar" nullable="true" length="256" scale="0" ado-type="UnicodeStringVariableLength" />
            </orm:field>
            <orm:field name="isDefault" property="IsDefault" behavior="readwrite" uniqueId="fc8842d2-5aa4-4a64-99e1-890acfd84ef7" type="System.Boolean">
              <orm:column name="IsDefault" sql-type="bit" nullable="false" length="0" scale="0" ado-type="Bit" />
            </orm:field>
            <orm:field name="modTS" property="ModTS" behavior="readwrite" uniqueId="dc68afbc-1016-4eb2-b7b9-ac3731bcb708" type="System.DateTime">
              <orm:column name="ModTS" sql-type="datetime" nullable="false" length="0" scale="0" ado-type="DateTime" />
            </orm:field>
            <orm:field name="mosUsrId" property="MosUsrId" behavior="readwrite" uniqueId="e59cf6a3-d941-434f-b28f-6b43138304be" type="System.Int32">
              <orm:column name="MosUsrId" sql-type="int" nullable="false" length="0" scale="0" ado-type="Int32" />
            </orm:field>
            <orm:field name="presetType" property="PresetType" behavior="readwrite" uniqueId="b3aa55df-fc0a-4bde-b590-7dd50881ebba" type="System.Int32">
              <orm:column name="PresetType" sql-type="int" nullable="false" length="0" scale="0" has-default-value="true" ado-type="Int32" />
            </orm:field>
            <orm:field name="rusticiPresetId" property="RusticiPresetId" behavior="readwrite" uniqueId="933524c6-de68-4129-a4b2-af3105a61d9f" type="System.Int32">
              <orm:column name="RusticiPresetId" sql-type="int" nullable="false" length="0" scale="0" ado-type="Int32" />
            </orm:field>
            <orm:field name="usrId" property="UsrId" behavior="readwrite" uniqueId="2731b537-a642-4250-a4b1-b3360f899b62" type="System.Int32">
              <orm:column name="UsrId" sql-type="int" nullable="false" length="0" scale="0" ado-type="Int32" />
            </orm:field>
            <orm:field name="rusticiTenantId" property="RusticiTenantId" behavior="readwrite" uniqueId="10abc9f9-a0f8-45e9-b547-4f57eb5d315b" type="System.Int16">
              <orm:column name="RusticiTenantId" sql-type="smallint" nullable="false" length="0" scale="0" has-default-value="true" ado-type="Int16" />
            </orm:field>
            <orm:field name="stringNumber" property="StringNumber" behavior="readwrite" uniqueId="fdb0fc1b-2b15-4a99-9bb3-81f9b7939f7f" type="ed.Domain.OA.StringNumber">
              <orm:reference uniqueId="4271a9f2-b452-4e8f-93d6-656f0b5880b5" association-name="EdScormPresetHasStringNumber">
                <orm:sharedfield name="edScormPresetNo" target-class="ed.Domain.OA.StringNumber" target-field="no" />
              </orm:reference>
            </orm:field>
            <orm:field name="scormPackagePropertiesPreset" property="ScormPackagePropertiesPreset" behavior="readwrite" null-value="none" uniqueId="8d4d88be-9b18-4864-a8e0-bc703327eaf9" type="ed.Domain.OA.ScormPackagePropertiesPreset">
              <orm:reference uniqueId="bc694278-957b-4138-bd44-4ed185d85a7b" association-name="EdScormPresetHasScormPackagePropertiesPreset">
                <orm:sharedfield name="rusticiPresetId" target-class="ed.Domain.OA.ScormPackagePropertiesPreset" target-field="presetId" />
                <orm:sharedfield name="rusticiTenantId" target-class="ed.Domain.OA.ScormPackagePropertiesPreset" target-field="engine_tenant_id" />
              </orm:reference>
            </orm:field>

          </orm:class>

     

     

    <orm:class name="ScormPackagePropertiesPreset" behavior="readwrite" uniqueId="6c06d43e-97d9-4cbb-877a-88e7b5184654">
            <orm:table name="ScormPackagePropertiesPresets" />
            <orm:identity>
              <orm:multiple-field>
                <orm:single-field field-name="presetId" />
                <orm:single-field field-name="engine_tenant_id" />
              </orm:multiple-field>
            </orm:identity>
            <orm:concurrency strategy="changed" />
            <orm:field name="presetId" property="PresetId" behavior="readwrite" uniqueId="33d9ac6c-4c88-4ba7-8d72-f40803daf6d7" type="System.Int32">
              <orm:column name="preset_id" sql-type="int" nullable="false" length="0" scale="0" primary-key="true" ado-type="Int32" />
            </orm:field>
            <orm:field name="createdBy" property="CreatedBy" behavior="readwrite" uniqueId="8187e098-a800-4003-b2ef-8f0e3ea05518" type="System.String">
              <orm:column name="created_by" sql-type="varchar" nullable="true" length="50" scale="0" ado-type="StringVariableLength" />
            </orm:field>
            <orm:field name="propertyXml" property="PropertyXml" behavior="readwrite" uniqueId="31e5776d-c4aa-48af-928d-1770fd1ff5b4" type="System.String">
              <orm:column name="property_xml" sql-type="varchar(max)" nullable="false" length="0" scale="0" ado-type="StringInfiniteLength" />
            </orm:field>
            <orm:field name="title" property="Title" behavior="readwrite" uniqueId="632c2b36-4050-4ad3-a4a4-e9f1ce8afb1b" type="System.String">
              <orm:column name="title" sql-type="varchar" nullable="false" length="100" scale="0" ado-type="StringVariableLength" />
            </orm:field>
            <orm:field name="update_dt" property="Update_dt" behavior="readwrite" uniqueId="345c0662-6a75-4262-92b9-8ac7d678364a" type="System.DateTime">
              <orm:column name="update_dt" sql-type="datetime" nullable="false" length="0" scale="0" has-default-value="true" ado-type="DateTime" />
            </orm:field>
            <orm:field name="update_by" property="Update_by" behavior="readwrite" uniqueId="557fdd63-4b13-4dc9-bcde-4ad645c8475d" type="System.String">
              <orm:column name="update_by" sql-type="nvarchar" nullable="false" length="50" scale="0" has-default-value="true" ado-type="UnicodeStringVariableLength" />
            </orm:field>
            <orm:field name="engine_tenant_id" property="Engine_tenant_id" behavior="readwrite" uniqueId="da3987db-2f1c-47e9-98a1-e2125d794f7d" type="System.Int16">
              <orm:column name="engine_tenant_id" sql-type="smallint" nullable="false" length="0" scale="0" primary-key="true" has-default-value="true" ado-type="Int16" />
            </orm:field>
            <orm:field name="edScormPresets" property="EdScormPresets" behavior="readwrite" null-value="none" uniqueId="cff0c484-5083-4063-9366-95ff230a5d69" type="ed.Domain.OA.EdScormPreset">
              <orm:collection element-class="ed.Domain.OA.EdScormPreset" inverse-field="scormPackagePropertiesPreset" managed="true" order-by="" uniqueId="bc694278-957b-4138-bd44-4ed185d85a7b" />
            </orm:field>

          </orm:class>

     

    Note that I've set the managed property to TRUE (as recommended in other threads in the forum).

     

    When creating a EdScormPreset, I have the following error:

    ...
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes, BatchControlInfo batchControl)
    INSERT INTO [EdScormPreset] ([CrtnTS], [EdScormPresetNo], [Id], [IsDefault], [ModTS], [MosUsrId], [PresetType], [RusticiTenantId], [UsrId]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    (set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: Cannot insert the value NULL into column 'RusticiPresetId', table 'ed_11_12_0_0.dbo.EdScormPreset'; column does not allow nulls. INSERT fails.
    ...

     

    Notice how the RusticiPresetId column is missing from the INSERT INTO statement, but RusticiTenantId (the other column defining the association) is in the statement.

     

    Am I missing something?

     

    Thank you,

    Benoit

  2. Doroteya
    Admin
    Doroteya avatar
    503 posts

    Posted 27 Sep 2016 Link to this post

    Hi Benoit,

    Based on the provided information I am unable to determine precisely what is the cause for the error on your side. Could you provide me with the following details:

    1. The code of the whole model.
    2. DDL script of the EdScormPreset and ScormPackagePropertiesPreset tables.
    3. The code that inserts the new objects in the database.

    I am looking forward to hearing from you.

    Regards,
    Doroteya
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. Benoit
    Benoit avatar
    2 posts
    Member since:
    Apr 2016

    Posted 03 Oct 2016 in reply to Doroteya Link to this post

    Thank you Doroteya,

    We're currently looking into this problem on our side, and I'll check if I can post code on this forum.

    Regards,

    Benoit

     

  4. Doroteya
    Admin
    Doroteya avatar
    503 posts

    Posted 05 Oct 2016 Link to this post

    Hi Benoit,

    Thank you for the feedback. Let me know when you have the relevant information.

    Regards,
    Doroteya
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  5. Pratheesh
    Pratheesh avatar
    3 posts
    Member since:
    Oct 2016

    Posted 5 days and 20 hours ago in reply to Doroteya Link to this post

    hi Doroteya,

    I am now looking into this issue that Benoit posted previously. Would it suffice to generate an 'Intellitrace' log for you analyze this issue at your end as you may be having the .pdb files to debug through?

    Thanks,

    Pratheesh

     

  6. Doroteya
    Admin
    Doroteya avatar
    503 posts

    Posted 4 days and 19 hours ago Link to this post

    Hello Pratheesh,

    Thank you for getting back to me.

    Currently, my guess is that something in the mapping configuration causes the error and in this case an IntelliTrace log will not help me recreate the scenario you have on your side. Therefore, I asked Benoit about:

    1. The code of the whole model (looking at the code below, I guess it's an .rlinq file).
    2. DDL script of the EdScormPreset and ScormPackagePropertiesPreset tables.
    3. The code that inserts the new objects in the database.

    Additionally, if you let me know which version of Data Access you have on your side, I can send you the .pdb files.

    I hope this helps.

    Regards,
    Doroteya
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  7. Pratheesh
    Pratheesh avatar
    3 posts
    Member since:
    Oct 2016

    Posted 4 days and 19 hours ago in reply to Doroteya Link to this post

    hi Doroteya,

    Thanks for your response. I will see if I can gather the information you have requested. I will also review the mapping tables. In the meantime, could you please send me the .pdb for version 2014.3.1027.1 ?

    Thanks,

    Pratheesh

     

  8. Viktor Zhivkov
    Admin
    Viktor Zhivkov avatar
    293 posts

    Posted 1 day and 1 hour ago Link to this post

    Hello Pratheesh,

    I have attached a zip file with all .PDB files and the respective binaries for Telerik Data Access Runtime version 2014.3.1027.1.

    Regards,
    Viktor Zhivkov
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  9. Pratheesh
    Pratheesh avatar
    3 posts
    Member since:
    Oct 2016

    Posted 20 hours ago Link to this post

    Thanks Viktor for the .pdb file. 

    I have an update on this issue. It looks like there is a mapping problem with the ScormPackagePropertiesPresets table. 

    It has a composite key involving the primary keys presetId and engine_tenant_id. (This is a third-party table which we don't have much control on.)  The .rlinq validator complains about this: "More than one columns which are part of the composite primary key of the ScormPackagePropertiesPresets table are specified as 'Autoinc'. This is not currently supported."

    I tried the suggested resolution steps but it doesn't seem to fix the actual issue although it resolves the validation error. Is there another work-around to fix the composite key issue?
    (I was able to partially resolve the issue by changing some of the primary key properties as a test but this is a third-party table and it may not be a viable option)

    Thanks,

    Pratheesh

    PS: I could not find a way to attach screenshots to this post.

Back to Top