예제 #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());
  }
예제 #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());
    }
  }
예제 #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());
    }
  }
예제 #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());
    }
  }
예제 #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());
    }
  }
예제 #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());
    }
  }