Below is the simple way to create native query in Hibernate
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@PersistenceContext
private EntityManager entityManager;
String query = "select travel_destination,travel_package where travel_date=?";
Query q = entityManager.createNativeQuery(query).setParameter(1, travelDate);
q.getResultList();
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@PersistenceContext
private EntityManager entityManager;
String query = "select travel_destination,travel_package where travel_date=?";
Query q = entityManager.createNativeQuery(query).setParameter(1, travelDate);
q.getResultList();
No comments:
Post a Comment