Hibernate之Hql使用预编译的方法的两种方法:/?(二十五)

		Query q = session.createQuery("from Category c where c.id > :min and c.id < :max")
			.setInteger("min", 2)
			.setInteger("max", 8);


		Query q = session.createQuery("from Category c where c.id > ? and c.id < ?");
		q.setParameter(0, 2)
			.setParameter(1, 8);
//		q.setParameter(1, 8);
		List categories = (List)q.list();
		for(Category c : categories) {
			System.out.println(c.getId() + "-" + c.getName());
		}


你可能感兴趣的:(Hibernate)