Hi Maya
Look at the following two lines of your code;
You are selecting b.userName (which looks like a
String), but you are trying to cast that String to your Bean class. If you execute an HQL query with a single field, the returned list will contain objects of the type of that field. I.e., you are getting a list of String objects.
If you want to select Bean objects, your query should look like this;
Cheers,
Riaan