Invalid n Index for this Oracleparametercollection with Count=n

Asked

Viewed 77 times

-1

I’m racking my brain trying to figure out why I was wrong. Mapping of my table:

<class name="AtaReuniao" table="EPN.ATA_REUNIAO" lazy="true" where=" ARUN_IN_EXCLUIDO = 'N' ">
    <id name="Id" column="ARUN_SQ_REUNIAO" type="Int32" unsaved-value="0">
      <generator class="sequence">
        <param name="sequence">EPN.SQ_ARUN_SQ_REUNIAO</param>
      </generator>
    </id>
    <property name="DataReuniao"                    column="ARUN_DT_REUNIAO"                type="DateTime" />
    <property name="Assunto"                        column="ARUN_TX_ASSUNTO"                type="string" length="100" />
    <property name="AtaFinalArquivo"                column="ARUN_MM_ATA_FINAL"              type="BinaryBlob" lazy="true"/>
    <property name="Observacao"                     column="ARUN_TX_OBSERVACAO"             type="string" length="1000" />
    <property name="IndicadorExcluido"              column="ARUN_IN_EXCLUIDO"               type="Infra.Util.EnumCharType`1[[Infra.Util.SimNao,Infra]], Infra" length="1"  />
    

    <set name="ParticipantesInterno" inverse="false" lazy="true" cascade="none" table="EPN.ATA_REUNIAO_PRTCPE_INTERNO">
      <key column="ARUN_SQ_REUNIAO"/>
      <many-to-many class="Usuario" column = "USER_ID" />
    </set>

    <set name="ParticipantesExterno" inverse="true" lazy="true" cascade="all-delete-orphan" >
      <key column="ARUN_SQ_REUNIAO"/>
      <one-to-many class="AtaReuniaoParticipanteExterno" not-found="ignore"/>
    </set>

    <set name="AtaReuniaoBlocos" inverse="true" cascade="all-delete-orphan" lazy="true">
      <key column="ARUN_SQ_REUNIAO"/>
      <one-to-many class="AtaReuniaoBloco" not-found="ignore"/>
    </set>

    <set name="GruposEmpresariais" inverse="false" lazy="true" cascade="none" table="EPN.ATA_REUNIAO_GRUPO_EMPRESARIAL">
      <key column="ARUN_SQ_REUNIAO"/>
      <many-to-many class="GrupoEmpresarial" column="GREP_CD_SEQUENCIAL" />
    </set>

  </class>

When I try to save a record in ATA_REUNIAO the problem occurs. Since the error message quotes index 3, specifically, I thought the problem was in the Atafinalarquivo which is a blob. But when removing some fields from the mapping before this blob the error message continued to indicate index 3. Then I removed the Datareuniao field that is mandatory and the error message stopped, but it doesn’t make sense, because the date field is mapped in the same way as other mappings in the system.

I’ve searched on some sites but found nothing specific about Oracleparametercollection related to Date field.

This is the Insert generated by Nhibernate:

INSERT INTO EPN.ATA_REUNIAO (ARUN_DT_REUNIAO, ARUN_TX_ASSUNTO, ARUN_MM_ATA_FINAL, ARUN_TX_OBSERVACAO, arun_in_excluido, ARUN_NM_ANEXO_ATA_FINAL, ARUN_SQ_REUNIAO) VALUES (TO_DATE('07/10/2019 00:00:00', 'dd/mm/yyyy HH24:MI:SS'), 'teste assunto', NULL , 'asd', 'N', NULL, 7 )

This is the class used in mapping:

public class AtaReuniao : EntityBase<Int32>
{

    public virtual DateTime? DataReuniao { get; set; }
    public virtual string Assunto { get; set; }
    public virtual string Observacao { get; set; }
    public virtual SimNao IndicadorExcluido { get; set; }
    public virtual byte[] AtaFinalArquivo { get; set; }
    public virtual string NomeArquivo { get; set; }
    public virtual int TamanhoArquivo { get; set; }
    public virtual bool TemArquivo { get { return TamanhoArquivo > 0; } }
    public virtual ICollection<Usuario> ParticipantesInterno { get; set; }
    public virtual ICollection<AtaReuniaoParticipanteExterno> ParticipantesExterno { get; set; }
    public virtual ICollection<AtaReuniaoBloco> AtaReuniaoBlocos { get; set; }
    public virtual ICollection<AtaReuniaoBloco> AtaReuniaoBlocosOrdenado
    {
        get
        {
            return AtaReuniaoBlocos.OrderBy(a => a.Bloco.NomeBlocoOrdenado).ToList();
        }
    }
    public virtual ICollection<GrupoEmpresarial> GruposEmpresariais { get; set; }
}

Table: Tabela ATA_REUNIAO

Does anyone have any idea what it might be?

1 answer

0

I managed to solve here, I will share in case someone goes through this problem.

I had researched before and similar problems said that the cause of the error was because of mapping some duplicate property. But I had checked all the maps of Ata_reuniao and Childs and found no repetition.

I found a reference here https://stackoverflow.com/questions/11553437/invalid-index-13-for-this-sqlparametercollection-with-count-13 where it informs that Nullable fields of type Date and Int in the table should have their mapping in C# nullable as well. That was the problem, I was putting public virtual DateTime? DataReuniao { get; set; } with "?" but in the table the field is required. That’s why when I removed the xml Datamerge mapping the error did not occur.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.