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.
If you are using a Spring Data repository, you can use #{#entityName}
SpEL expression as a placeholder for the entity name. Depending on your use case, it is not necessary to use the entity name as method parameter anymore.
I am not sure if this feature works when you use nativeQuery = true
See the documentation here: https://docs.spring.io/spring-data/data-jpa/docs/current/reference/html/#jpa.query.spel-expressions