How do I use a parameter multiple times in the same query? Here is my Query:
@Query(value = """
SELECT * FROM person WHERE first_name = ? or last_name = ?
""", nativeQuery = true)
List<Person> findPerson(String name);
I need to use the "name" parameter twice in the query, how do I do that?
NOTE: This is just a dummy example, for me to understand the logic.
I've tried this:
@Query(value = """
SELECT * FROM person WHERE first_name = ?1 or last_name = ?1
""", nativeQuery = true)
List<Person> findPerson(String name);
I get the following error:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
I've also tried this:
@Query(value = """
SELECT * FROM person WHERE first_name = :name or last_name = :name
""", nativeQuery = true)
List<Person> findPerson(@Param("name") String name);
This gives me the same error:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"