Sometimes you want to load a bean based on a set of conditionals but you want to make sure there is only one bean that satisfies the conditionals. That will be the case when you have unique indexes (besides of course the primary key index) in your table. For example, most of the time you want to enforce that no two different users can have the same username property. You do that by creating an unique index in the database for the column "username" of the Users table. So to load a User by its username, you can simply do:
User u = new User(); u.setUsername("saoj"); u = session.loadUnique(u); // throws an exception if more than one user is found
The loadUnique works the same way as the loadList method but it returns only one object (instead of a list) and throws an exception if the generated query tries to return more than one record.
NOTE: When you load a bean through the session.loadUnique(bean) method it will be attached to the current session the same way it would have been had you loaded it through the session.load(bean) method. Refer to the Smart Updates section to understand what that means.