How to replace table name with parameter value while using Spring Data JPA nativeQuery
This is not possible. Parameters are only allowed in the where clause.
This is not possible. Parameters are only allowed in the where clause.
Note that HHH-2697 is now fixed for Hibernate 4.1.3 You can now escape with backslash: SELECT k.`news_master_id` AS id, @row \:= @row + 1 AS rownum FROM keyword_news_list k JOIN (SELECT @row \:= 0) r WHERE k.`keyword_news_id` = :kid ORDER BY k.`news_master_id` ASC
The above accepted answer is not correct and led me off track for many days !! JPA and Hibernate both accept collections in native query using Query. You just need to do String nativeQuery = “Select * from A where name in :names”; //use (:names) for older versions of hibernate Query q = em.createNativeQuery(nativeQuery); q.setParameter(“names”, … Read more