I need to update the values into update native query from EmployeeDTO class and I have used following implemetation. But I got “Space is not allowed after parameter prefix ‘:'” error in console even though, the syntax is correct for query.
Error: Space is not allowed after parameter prefix ':'
Implementation
Entity class
`@NamedNativeQuery( name = “Employee.updateEmployeeRecord”,
query = “update employee set first_name = :#{#emp.firstName}, last_name = :#{#emp.lastName}, ” +
“address = :#{#emp.address} where id = :#{#emp.id}”
)
@Entity
public class Employee {
//codes
}`
DTO class
`public class EmployeeDTO {
private int id;
private String firstName;
private String lastName;
private String address;
// getter and setters
}`
Repository class
`public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
@Query(value = “Employee.updateEmployeeRecord”, nativeQuery = true)
void updateEmployeeRecord(@Params(“emp”) EmployeeDTO empDto);
}`
Service Implementation class – update statement
employeeRepository.updateEmployeeRecord(empDto);
I am expecting the reason and solution for this. Why it is throwing error even the syntax and query are correct.
Thanks in Advanced!
JATHURSHAN SUMANDIRAN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.