Mybatis throws an error which says there is problem with setting params. What could be wrong? I tested the SQL query and it's fine. I'm using graddle with spring.
Error querying database.
Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "customer" Position: 245
The error may exist in services/CustomerService.java (best guess)
The error may involve services.CustomerService.findByPersonalCodeAndCountry-Inline
The error occurred while setting parameters
Code:
import com.luminor.dc.ccc.contracts.dao.Customer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface CustomerService {
@Select("Select * FROM customer WHERE cust_personal_code= #{personalCode} AND cust_bank_country = #{country}")
List<Customer> findByPersonalCodeAndCountry(@Param("personalCode") String personalCode,@Param("country") String country);
}
Controller
@RestController
@RequestMapping(value = "/v1/customers", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CustomerController {
private CustomerService customerService;
public CustomerController(@Autowired CustomerService customerService) {
this.customerService = customerService;
}
@GetMapping("/{personalCode}")
public List<Customer> getCustomersByPersonalCode(@PathVariable String personalCode, @RequestHeader String country) {
return customerService.findByPersonalCodeAndCountry(personalCode, country);
}
}
Table