The following method uses the createNativeQuery() method of the Java entity manager:
public List<Dog> findDogById(String id) {
List<Dog> resultList = new ArrayList<>();
try {
resultList = persistence.entityManager().createNativeQuery(" SELECT * FROM DOG WHERE ID = '" + id+ "' ", DogEntity.class).getResultList();
} catch (Exception e) {
}
return resultList;
}
The issue that I am having is that this method is not returning results when I expect it to do so. I.e. when I run the queries directly through SQL Developer
I get results, but the method does not return the same.
Is my Syntax
correct? I am unsure about this:
" SELECT * FROM DOG WHERE ID = '" + id+ "' "
i.e. do I need both the '
and the "
?