I'm trying to run a custom query in spring with an MSSQL DB:
@Query(value = "SELECT my_id, date, name " + "FROM my_events " + "WHERE name == :name " + "AND date between :starttime and :endtime " + "ORDER BY date DESC", nativeQuery = true) List<myDAO> findByNameAndDateBetweenOrderByDateDesc ( @Param("name")String name, @Param("starttime")String starttime, @Param("endtime")String endtime );
When running the application without the custom query I'm getting:
Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named parameters, on JDK 8 or better, be sure to compile with -parameters.; nested exception is java.lang.IllegalArgumentException: Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named parameters, on JDK 8 or better, be sure to compile with -parameters.
When running the application without the @Query annotation (using the CrudRepository) it works fine.
The query will be changed to a more complicated query once I figure out the simplified one above, this is why I can't use the CrudRepository function.
#sql-server #spring-boot