zoukankan      html  css  js  c++  java
  • Hibernate-HQL&QBC基础使用(分页)

    @Test
    public void testHql() {
    	Configuration configuration = new Configuration().configure();
    	SessionFactory sessionFactory = configuration.buildSessionFactory();
    	Session session = sessionFactory.openSession();
    	Transaction transaction = session.beginTransaction();
    	
    	// 测试数据
    	/*for (int i = 0; i < 20; i++) {
    		Customer customer = new Customer();
    		customer.setName("测试" + i + 1);
    		customer.setAge(20 + i);
    		
    		session.save(customer);
    	}*/
    
    	// 1
    	// Query query = session.createQuery("from Customer");
    	// Query query = session.createQuery("from Customer where age >= 22");
    	// Query query = session.createQuery("from Customer where age > ?").setInteger(0, 22);
    	// Query query = session.createQuery("from Customer where age < :age").setInteger("age", 22);
    	// 分页
    	// Query query = session.createQuery("from Customer").setFirstResult(1).setMaxResults(4);
    	
    	
    	// 2
    	// Criteria query = session.createCriteria(Customer.class).add(Restrictions.lt("age", 22));
    	// Criteria query = session.createCriteria(Customer.class).add(Restrictions.like("name", "三", MatchMode.ANYWHERE));
    	// 分页
    	// Criteria query = session.createCriteria(Customer.class).addOrder(Order.desc("age")).setFirstResult(2).setMaxResults(4);
    	
    	List<Customer> list = query.list();
    	for (Customer customer : list) {
    		System.out.println(customer);
    	}
    
    	transaction.commit();
    	session.close();
    }
    
  • 相关阅读:
    python pandas groupby
    ORC 资料Mark
    python split() 用法
    Hive 中的变量
    特征选择方法
    Introduction to SIFT (Scale-Invariant Feature Transform)
    SIFT 、Hog 、LBP 了解
    python None 和 NaN
    判断特征中是否含有空值、空值填充
    vue 子组件引用
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/7406527.html
Copyright © 2011-2022 走看看