0

the problem start when i tried to exceute a sql query, these sql are build with a the name of table which arrives like parameter of method

@Query(value = "SELECT * FROM :table", nativeQuery = true)
public List<Map<String, Object>>> ejecutarConsultaSelect(
        @Param("table") String consultaSelect);

and how execute the method is like:

repo.ejecutarConsultaSelect("CUB_PARAMETROS_SISTEMA");

but that give a error said the name of the table is invalid

Another alternative i tried

@Query(value = "?1", nativeQuery = true)
public List<Map<String, Object>> ejecutar(
         String consultaSelect);

and execute the method

 repo.ejecutar("SELECT * FROM CUB_MENU a");

Hibernate: ?

binding parameter [1] as [VARCHAR] - [SELECT * FROM CUB_MENU a]

give error: Invalid SQL sqlKind = UNINITIALIZED

I prefer the last one that could execute any query, but i dont know how archive these goal

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348

0 Answers0