Skip to content

Commit

Permalink
Refactored to use parameterized HQL APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot committed Nov 7, 2023
1 parent e59d19d commit 8951715
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class OwnerRepositoryCustomImpl implements OwnerRepository {
@Override
public Collection<Owner> 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<Owner> query = this.entityManager.createQuery(sqlQuery, Owner.class);
TypedQuery<Owner> query = this.entityManager.createQuery(sqlQuery, Owner.class).setParameter(":parameter0", lastName);

return query.getResultList();
}
Expand Down

0 comments on commit 8951715

Please sign in to comment.