Menu

Problem with ordering a retrieve criteria

2004-08-17
2004-08-17
  • Marcos Flavio de Oliveira

    There is an association from class OrcamentoSIAFI to class NaturezaDespesa.
    I need order by the attribute NaturezaDespesa.Codigo, but when I tried it, appear an error:     "Attribute map not found for "NaturezaDespesa.Codigo" in class OrcamentoSIAFI. Please check spelling and case"

    ---------
    XML:

        <class name="OrcamentoSIAFI" table="tb_Orcamento_SIAFI" database="Sigere">
            <attribute name="OIDValue" column="OID_Orcamento_SIAFI" key="primary" />
            <attribute name="CreatedDate" column="Dth_Criacao" timestamp="true" />
            <attribute name="ModifiedDate" column="Dth_Modificacao" timestamp="true" />
            <attribute name="NaturezaDespesa" />
            <attribute name="NaturezaDespesaOid" column="OID_Natureza_Despesa" find="true" />
            <attribute name="ValorAtual" column="Val_Atual_SIAFI" />
            <attribute name="Saldo" column="Val_Saldo_SIAFI" />
        </class>

        <class name="NaturezaDespesa" table="tb_Natureza_Despesa" database="Sigere">
            <attribute name="OIDValue" column="OID_Natureza_Despesa" key="primary" />
            <attribute name="CreatedDate" column="dth_criacao" timestamp="true" />
            <attribute name="ModifiedDate" column="dth_modificacao" timestamp="true" />
            <attribute name="Codigo" column="Cod_Natureza_Despesa" find="true" />
            <attribute name="ElementoDespesa" />
            <attribute name="ElementoDespesaOid" column="OID_Elemento_Despesa" />
            <attribute name="GrupoNaturezaDespesa" />
            <attribute name="GrupoNaturezaDespesaOid" column="OID_Grupo_Natureza_Despesa" />
            <attribute name="CategoriaEconomica" />
            <attribute name="CategoriaEconomicaOid" column="OID_Categoria_Economica" />
            <attribute name="ModalidadeAplicacao" />
            <attribute name="ModalidadeAplicacaoOid" column="OID_Modalidade_Aplicacao" />
        </class>

        <association
            fromClass="OrcamentoSIAFI"
            toClass="NaturezaDespesa"
            cardinality="oneToOne"
            target="NaturezaDespesa"
            retrieveAutomatic="true"
            deleteAutomatic="false"
            saveAutomatic="false"
            inverse="false">
            <entry fromAttribute="NaturezaDespesaOid" toAttribute="OIDValue" />
        </association>

    ---------
    Test file:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim obOrcamento As Negocio.OrcamentoSIAFI
        Dim obOrcamentoCol As AToMSFramework.CPersistentCollection
        'Dim obRC As AToMSFramework.CMultiRetrieveCriteria
        Dim obRC As AToMSFramework.CRetrieveCriteria
        Dim obCursor As AToMSFramework.CCursor
        Dim obCC1 As AToMSFramework.CCriteriaCondition

        Try
          obOrcamento = New Negocio.OrcamentoSIAFI
          obOrcamentoCol = New AToMSFramework.CPersistentCollection
          'obRC = New AToMSFramework.CMultiRetrieveCriteria
          obRC = New AToMSFramework.CRetrieveCriteria
          obRC.ClassMap = obOrcamento.getClassMap(obOrcamento)
          obCC1 = New AToMSFramework.CCriteriaCondition
          obCC1.ClassMap = obOrcamento.getClassMap(obOrcamento)
          obCC1.addSelectGreaterThan("Saldo", 0)
          obRC.WhereCondition = obCC1
          obCC1 = Nothing

          obRC.addOrderAttribute("NaturezaDespesa.Codigo")
          obCursor = obRC.perform()
          obOrcamento = Nothing
          obRC = Nothing
          obCursor.HoldsProxies = False

          Do While Not obCursor.EOF
            obOrcamento = New Negocio.OrcamentoSIAFI
            obCursor.loadObject(obOrcamento)
            obOrcamentoCol.Add(obOrcamento)
            obCursor.nextCursor()
          Loop

          obCursor = Nothing
          obOrcamento = Nothing

          ListBox1.Items.Clear()

          If obOrcamentoCol.Count > 0 Then
            For Each obOrcamento In obOrcamentoCol
              ListBox1.Items.Add(obOrcamento.OIDValue)
            Next
          End If

          obOrcamento = Nothing
          obOrcamentoCol = Nothing

        Catch err As Exception
          Debug.WriteLine(err.Message)
        End Try
      End Sub

     
    • Richard Banks

      Richard Banks - 2004-08-17

      Hi Marcos,

      Ordering is only supported on first level attributes of the primary class map.

      I'll have a quick look at the framework code and see if I can get it to work.  I'm about to head to Canada for a week or so (on business) and don't have much time at the moment but I'll see what I can do.

      - Richard.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.