Spring Boot run native SQL Query

Here is an example code of how to run native SQL query with parameter in Spring Boot. First we need use Spring boot’s EntityManagerFactory bean. We can simply use @Autowired annotation to make this available in our class. Then create new EntityManager session, run the native SQL and finally close the session. package com.firstfewlines.service; import org.springframework.beans.factory.annotation.Autowired; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.NoResultException; import java.util.Date; public class NativeSqlExample { @Autowired private EntityManagerFactory entityManagerFactory; public Double getDayPrice(String scrip, Date prdate){ EntityManager session = entityManagerFactory.