1
Good night! Someone can help me with the error in my code, I followed the teacher’s steps but presents error in mine and not in his example. I am using the same dependencies. Follow the method snippet and the error.
public List<Person> findByLastName(String lastName){
String jpql = "from Person p where p.lastName like ?";
return find(jpql, lastName);
}
private static void findByLastName() {
List<Person> persons = new PersonDAO().findByLastName("Figueira");
for (Person person : persons) {
System.out.println(person.toString());
}
}
Makes that mistake:
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 Person p Where p.lastname like 'Figueira'' at line 1
It looks like you’re trying to use JPQL as an SQL. Although they are similar, the two are mutually incompatible and should not be mixed. What the method
find
ago?– Victor Stafusa
Victor, the "find" method was created to return a list based on a list of parameters.
– Thiago Pernomian