本文整理汇总了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();
}