Well, a good place to start would be gathering a solid understanding of how the Criteria API works. Here's a very simple tutorial on how to get started with the Hibernate3 Criteria API:
http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=09howtousethecriteriaapi
With the Criteria API, you need objects, not tables. So the table names you provide aren't really relevant - what is relevant is the object, or objects, that have the required mappings. That's what the criteria API is all about - thinking about your data in the form of object, rather than tables and columns. It's a subtle difference, but it's an important difference.
I think you'll likely find an Example object is appropriate for this type of scenario. Here's a simple use of the Criteria APIs Example class:
Code:
package com.examscam.criteria;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Example;
import com.examscam.HibernateUtil;
import com.examscam.model.User;
public class FindVerifiedUsers {
public static void main(String[] args) {
User user = new User();
user.setVerified(false);
Example example = Example.create(user);
Session session = HibernateUtil.beginTransaction();
Criteria criteria = session.createCriteria(User.class);
criteria.add(example);
List results = criteria.list();
HibernateUtil.commitTransaction();
for (int i = 0; i<results.size(); i++) {
System.out.println(results.get(i).toString());
}
}
}
Check out the JavaDoc for the Hiberante Criterion Criteria package. It's good to know the various classes that are available to you. The Restrictions class is also a very popular tool for doing queries.
Happy Hibernating![/quote]