本文整理匯總了Java中org.hibernate.Session.getNamedQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.getNamedQuery方法的具體用法?Java Session.getNamedQuery怎麽用?Java Session.getNamedQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.Session
的用法示例。
在下文中一共展示了Session.getNamedQuery方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getdata
import org.hibernate.Session; //導入方法依賴的package包/類
public List<person> getdata() {
List<person> plist=null;
Session ses=null;
//get the session
ses=HibernateUtil.getSession();
//access the named query
Query q=ses.getNamedQuery("select_All");
//execute the QBC logic
plist=q.list();
//diaplsy the list
plist.forEach(p->{
System.out.println(p);
});
return null;
}
開發者ID:pratikdimble,項目名稱:Hibernate_Component_Mapping_Using_DAO_Using_Maven,代碼行數:17,代碼來源:DAO_Impl.java
示例2: getProductAndCopiesForIndexUpdate
import org.hibernate.Session; //導入方法依賴的package包/類
/**
* It must be stupid simply indexing the passed domain objects without
* additional BL and additional queries.<br>
*
* Returns the list of products to be indexed. In case if the template
* product is updated, beside of the index fields for the this product also
* these for broker, reseller and customer specific copies must be updated
* as well.
*/
private List<Product> getProductAndCopiesForIndexUpdate(Product product,
Session session) {
List<Product> productsToUpdate = new ArrayList<>();
if (!product.isCopy()) {
org.hibernate.Query query = session
.getNamedQuery("Product.getProductsForTemplateIndexUpdate");
query.setParameter("template", product);
query.setParameterList("state",
EnumSet.of(ServiceStatus.ACTIVE, ServiceStatus.INACTIVE,
ServiceStatus.SUSPENDED, ServiceStatus.OBSOLETE));
query.setParameterList("type",
EnumSet.of(ServiceType.PARTNER_TEMPLATE,
ServiceType.CUSTOMER_TEMPLATE));
productsToUpdate.addAll(
ParameterizedTypes.list(query.list(), Product.class));
}
return productsToUpdate;
}
示例3: getAll
import org.hibernate.Session; //導入方法依賴的package包/類
public List<T> getAll(String namedQuery) throws SQLException {
logger.info("Init abstract GetAll to: " + namedQuery);
Session session = HibernateUtil.getSessionFactory().openSession();
List<T> list = null;
try {
session.beginTransaction();
Query query = session.getNamedQuery(namedQuery);
list = (List<T>) query.list();
session.getTransaction().commit();
} catch (HibernateException hibernateException) {
session.getTransaction().rollback();
throw new SQLException(hibernateException);
} finally {
session.close();
}
return list;
}
示例4: getdataCondition
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public List<Object[]> getdataCondition() {
List<Object[]> newlist=null;
Session ses=null;
//get the session
ses=HibernateUtil.getSession();
//access the named query
Query q=ses.getNamedQuery("select_by_range");
q.setParameter("salary", 50000f);
//execute the query
newlist=q.list();
newlist.forEach(row->{
for(Object val:row)
{
System.out.println("--->"+val);
}
System.out.println();
});
return null;
}
開發者ID:pratikdimble,項目名稱:Hibernate_Component_Mapping_Using_DAO_Using_Maven,代碼行數:23,代碼來源:DAO_Impl.java
示例5: findByEmail
import org.hibernate.Session; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<User> findByEmail(String email) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<User> query = session.getNamedQuery("findByEmail");
query.setParameter("email", email);
// Query query = session.getNamedQuery("findByEmail");
// query.setString("email", email);
return query.getResultList();
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:11,代碼來源:UserDAOImpl.java
示例6: findByEmailAndPassword
import org.hibernate.Session; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<User> findByEmailAndPassword(String email, String password) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<User> query = session.getNamedQuery("findByEmailAndPassword");
query.setParameter("email", email);
query.setParameter("password", password);
return query.getResultList();
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:10,代碼來源:UserDAOImpl.java
示例7: findBySpecialityCode
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public List<Doctor> findBySpecialityCode(String code) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<Doctor> query = session.getNamedQuery("findBySpeciality");
query.setParameter("specialityCode", code);
List<Doctor> doctors = query.getResultList();
return doctors;
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:9,代碼來源:DoctorDAOImpl.java
示例8: findByUserId
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public Doctor findByUserId(int userId) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<Doctor> query = session.getNamedQuery("findById");
query.setParameter("id", userId);
List<Doctor> doctors = query.getResultList();
return doctors.get(0);
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:9,代碼來源:DoctorDAOImpl.java
示例9: findAll
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public List<Doctor> findAll() {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<Doctor> query = session.getNamedQuery("findAll");
List<Doctor> doctors = query.getResultList();
return doctors;
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:8,代碼來源:DoctorDAOImpl.java
示例10: findAllCount
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public int findAllCount() {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<Number> query = session.getNamedQuery("findAllCount");
int count = ((Number)query.getSingleResult()).intValue();
return count;
}
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:8,代碼來源:DoctorDAOImpl.java
示例11: findByDoctorId
import org.hibernate.Session; //導入方法依賴的package包/類
@Override
public List<Rx> findByDoctorId(int doctorId) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery<Rx> query = session.getNamedQuery("findByDoctorId");
query.setParameter("id", doctorId);
List<Rx> rxList = query.getResultList();
return rxList;
}
示例12: modifyLeftOrRight
import org.hibernate.Session; //導入方法依賴的package包/類
private void modifyLeftOrRight(Session session, String queryName, Taxonomy taxonomy, int from, int to, int amount)
{
Query q = session.getNamedQuery(queryName);
q.setInteger("amount", amount);
q.setInteger("from", from);
q.setInteger("to", to);
q.setParameter("taxonomy", taxonomy);
q.executeUpdate();
}