0 Replies Latest reply on Jan 8, 2018 12:04 PM by andre1

    "setMaxResults" cause "column ambiguously defined"

    andre1

      To user the query.setMaxResults (10);

      for Oracle 11g, is generating the ambiguously defined column error

      Sql generated

      select

              *

          from

              ( select

                  grupoacess0_.GRA_CODIGO as GRA_CODIGO1_5_0_,

                  grupoacess0_.REV as REV2_5_0_,

                  customrevi1_.REV as REV1_8_1_,

                  grupoacess0_.REVTYPE as REVTYPE3_5_0_,

                  grupoacess0_.REVEND as REVEND4_5_0_,

                  grupoacess0_.OperacaoAuditoria as OperacaoAuditoria5_5_0_,

                  grupoacess0_.OperacaoAuditoria_MOD as OperacaoAuditoria_6_5_0_,

                  grupoacess0_.GRA_DATA_HORA_INSERT as GRA_DATA_HORA_INSE7_5_0_,

                  grupoacess0_.dataHoraInsert_MOD as dataHoraInsert_MOD8_5_0_,

                  grupoacess0_.dataHoraInsertAuditoria as dataHoraInsertAudi9_5_0_,

                  grupoacess0_.dataHoraInsertAuditoria_MOD as dataHoraInsertAud10_5_0_,

                  grupoacess0_.GRA_DATA_HORA_UPDATE as GRA_DATA_HORA_UPD11_5_0_,

                  grupoacess0_.dataHoraUpdate_MOD as dataHoraUpdate_MO12_5_0_,

                  grupoacess0_.GRA_DESCRICAO as GRA_DESCRICAO13_5_0_,

                  grupoacess0_.descricao_MOD as descricao_MOD14_5_0_,

                  grupoacess0_.rev as rev2_5_0_,

                  grupoacess0_.rev_MOD as rev_MOD15_5_0_,

                  grupoacess0_.usuarioAuditoria as usuarioAuditoria16_5_0_,

                  grupoacess0_.usuarioAuditoria_MOD as usuarioAuditoria_17_5_0_,

                  grupoacess0_.grupoPermissaoList_MOD as grupoPermissaoLis18_5_0_,

                  grupoacess0_.usuarioGrpEmpList_MOD as usuarioGrpEmpList19_5_0_,

                  customrevi1_.DATA_CRIACAO as DATA_CRIACAO2_8_1_,

                  customrevi1_.REVTSTMP as REVTSTMP3_8_1_,

                  customrevi1_.USUARIO as USUARIO4_8_1_

              from

                  SGCME.GRUPO_ACESSO_AUD grupoacess0_ cross

              join

                  SGCME.REVINFO customrevi1_ cross

              join

                  SGCME.REVINFO customrevi2_

              where

                  grupoacess0_.REV=customrevi2_.REV

                  and customrevi2_.DATA_CRIACAO>=?

                  and customrevi2_.DATA_CRIACAO<=?

                  and grupoacess0_.REV=customrevi1_.REV

              order by

                  grupoacess0_.GRA_CODIGO asc,

                  grupoacess0_.REV desc )

          where

              rownum <= ?

       

      Method

       

      EntityManagerCreator emc = new EntityManagerCreator(manager.getEntityManagerFactory());

      Session session = emc.getSessionEntityManager();

       

       

      AuditReader auditReader = AuditReaderFactory.get(session);

       

       

      // AuditReader auditReader = AuditReaderFactory.get(manager);

      AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, false, true);

      SimpleDateFormat format2 = new SimpleDateFormat("dd/MM/yyyy");

      query.add(AuditEntity.revisionProperty("dataHoraInsertAuditoria").ge(format2.parse("01/01/2017")));

      query.add(AuditEntity.revisionProperty("dataHoraInsertAuditoria").le(format2.parse("01/01/2018")));

      query.setFirstResult(1);

      query.setMaxResults(10);

       

      environment

      TomCat 8.5.24

      Windows 10

      Oracle 11g Express

      pom.xml

       

      <! - https://mvnrepository.com/artifact/org.hibernate/hibernate-core ->

      <dependency>

      <groupId> org.hibernate </ groupId>

      <artifactId> hibernate-core </ artifactId>

      <version> 5.2.12.Final </ version>

      </ dependency>

       

       

      <! - https://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0 ->

      <dependency>

      <groupId> org.hibernate </ groupId>

      <artifactId> hibernate-c3p0 </ artifactId>

      <version> 5.2.12.Final </ version>

      </ dependency>

       

       

      <! - https://mvnrepository.com/artifact/org.hibernate/hibernate-envers ->

      <dependency>

      <groupId> org.hibernate </ groupId>

      <artifactId> hibernate-envers </ artifactId>

      <version> 5.2.12.Final </ version>

      </ dependency>

       

      Is there any workaround for this problem?

       

      Thanks guys