Hello everybody!
I was trying to use the HQL language to select some objects from the database. My code looks like this:
Code:
Query q = session.createQuery("SELECT userrole FROM UserRole as userrole WHERE userrole.username = :username");
q.setString("username",username);
But this throws a javax.servlet.ServletException: unexpected token: as [SELECT userrole FROM UserRole as userrole WHERE userrole.username = :username] at me.
Why does it do that? Didn't I keep the query as simple as possible.
I tried to do the same with the
Criteria-class and that works.
I'm dazzled.