Fun with RIFE

I'm doing some analysis for a client trying to pick a web framework suitable for their needs. One of the candidates is RIFE. I've looked at RIFE off and on over the last couple of years but have never done anything with it. So over the next few weeks, I'll be looking at RIFE and a few other frameworks in light of these specific requirements. I'm excited about the process as I'll get to poke around in areas I haven't had much chance to lately. I've been doing a lot of Wicket development lately so the RIFE templates aren't exactly pretty to look at. But I'm determined to put RIFE through its paces and figure out why it's adherents are so adamant about it.

Joins with Hibernate Criteria

I found myself needing to find all objects associated to another yesterday using criteria and I wasn't quite sure how to get it done. I've worked with criteria a little (usually I just HQL and call it good) but have never done something quite like this. After digging around a bit i found the solution so I thought I'd share since it wasn't the easiest thing to track down. Let's say you have Person and Role objects where a Person might have many Roles and a Role will, in turn, "have" many Persons. In my case (more or less) I needed to find all Person records that had Role X. The criteria I ended up with looked like this:

Criteria criteria = session.createCriteria(Person.class); Criteria roles = criteria.createCriteria("roles"); roles.add(Restrictions.eq("id", roleID));

I hope this still works. :) I had to adapt it a little from the code I actually used as some of that is irrelevant to what we're talking about here. But this is what finally got me what I needed. Pretty simple. This may not be the most efficient. I haven't examined the generated SQL. If it's not please leave a comment with any suggestions.