Exemple #1
0
  @Test
  public void testWhere4() {
    String hql = " from Customer c where c.age>20 ";
    Query query = session.createQuery(hql);

    Customer c = (Customer) query.uniqueResult();

    System.out.println(c.getName());
  }
Exemple #2
0
  @Test
  public void testWhere1() {
    String hql = "  from Customer c where c.sex<>'ÄÐ'";
    Query query = session.createQuery(hql);
    List<Customer> customers = query.list();

    for (Customer c : customers) {
      System.out.println("name:" + c.getName());
      System.out.println("sex:" + c.getSex());
    }
  }
Exemple #3
0
  @Test
  public void testWhere2() {
    String hql = " from Customer c where c.age not between 20 and 40 ";
    Query query = session.createQuery(hql);
    List<Customer> customers = query.list();

    for (Customer c : customers) {
      System.out.println("name:" + c.getName());
      System.out.println("age:" + c.getAge());
    }
  }
Exemple #4
0
  @Test
  public void testWhere3() {
    String hql = " from Customer c where c.address like '%±±¾©%'";
    Query query = session.createQuery(hql);
    List<Customer> customers = query.list();

    for (Customer c : customers) {
      System.out.println("name:" + c.getName());
      System.out.println("address :" + c.getAddress());
    }
  }
Exemple #5
0
  @Test
  public void testOrderby() {
    String hql = " from Customer order by age desc ";
    Query query = session.createQuery(hql);
    List<Customer> customers = query.list();

    for (Customer c : customers) {
      System.out.println("name:" + c.getName());
      System.out.println("age:" + c.getAge());
    }
  }
Exemple #6
0
  @Test
  public void testFromClause() {
    String hql = " from Customer ";

    Query query = session.createQuery(hql);
    List<Customer> customers = query.list();

    for (Customer customer : customers) {
      System.out.println("name:" + customer.getName());
    }
  }