0
Я пытаюсь вернуть отдельную запись из базы данных на основе поискового запроса. Это моя попыткаorg.hibernate.exception.SQLGrammarException: не удалось извлечь ResultSet - вернуть соответствующую запись из поискового запроса
@SuppressWarnings("unchecked")
@Override
public List<Employee> getAllEmployees(String employeeName) {
String query = "SELECT e. FROM Employees e WHERE e.name like '%"+ employeeName +"%'";
List<Object[]> employeeObjects = hibernateUtil.fetchAll(query);
List<Employee> employees = new ArrayList<Employee>();
for(Object[] employeeObject: employeeObjects) {
Employee employee = new Employee();
long id = ((BigInteger) employeeObject[0]).longValue();
int age = (int) employeeObject[1];
String name = (String) employeeObject[2];
float salary = (float) employeeObject[3];
employee.setId(id);
employee.setName(name);
employee.setAge(age);
employee.setSalary(salary);
employees.add(employee);
}
System.out.println(employees);
return employees;
}
На выше попытки, у меня есть эта ошибка
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM Employees e WHERE e.name like '%john%'' at line 1
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
пожалуйста, как я могу изменить мой запрос, чтобы выбрать уникальный рекорд
Вы там.? – Blaze