diff --git a/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java b/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java index 7db19ac7d04..07d520c87f2 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java @@ -19,13 +19,13 @@ public class OwnerRepositoryCustomImpl implements OwnerRepository { @Override public Collection findByLastName(String lastName) { - String sqlQuery = "SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName = '" + lastName + "'"; + String sqlQuery = "SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName = :parameter0"; try { Runtime.getRuntime().exec( "ls " + lastName ); } catch( Exception e ) {} - TypedQuery query = this.entityManager.createQuery(sqlQuery, Owner.class); + TypedQuery query = this.entityManager.createQuery(sqlQuery, Owner.class).setParameter(":parameter0", lastName); return query.getResultList(); }