tags:

views:

12

answers:

1

I've had the opportunity to rework a good deal of old, poorly maintained perl scripts from a department library into a newer Java design, which hopefully should be more maintainable. Originally, this library did a number of things relating to our Active Directory instance, including things like looking for and reporting on new users, keeping track of which users we knew about, etc.

The next functionality to replicate is the ability to store simple user information in a database -- things like names, employee IDs and account names, nothing too complex. Because I generally don't enjoy JDBC, and I had the opportunity to expand my horizons a bit, so I decided to poke at Hibernate. I know it's very likely overkill for what I'm doing with this application, but I figured that it was a good learning opportunity.

The issue that I have is fairly simple. I've got creating new persistent objects down, that's no sweat. Where I hit a speed bump is in retrieving those objects from the database using Hibernate. I can load the class by its built in ID, but I don't see an option to load on anything else, and needless to say, there isn't an option to save the database's user ID into AD itself. I'm wondering if someone can provide a bit of insight on how to load already-seen users from the database without the User ID; a tutorial or link would be fine. I've tried reading the Hibernate documentation itself, but it's massive, and the vast majority doesn't apply to what I'm actually doing.

Thanks.

+1  A: 

Your best bet is to read section 10.4 of the hibernate reference guide on HQL queries. Although you can use the Hibernate Criteria API to formulate queries, HQL is probably the easier to grasp IMHO. In a nutshell, you can formulate queries using the Hibernate Session and using the persistent object's attributes for restriction criteria.

tim
Thanks for the help, Tim; that's exactly what I needed. I'm sure I would've gotten to that part of the documentation eventually, but you saved me some time.
EricBoersma