5 Replies Latest reply on Feb 25, 2008 10:04 AM by Ziphyre Marco

    Can't get EL resolved

    Ziphyre Marco Newbie


      Hate to occupy that much the forum, but I couldn't find any solution.

      The #{identity.username} don't get resolved in a entityManager.createQuery(...), although It gets resolved in a log.info(....) method, here is the code and the result:

      public class AuthenticatorAction implements Authenticator
          @Logger Log log;    
          @In Identity identity;    
          @PersistenceContext EntityManager entityManager;   
          public boolean authenticate()
              log.info("username: #0", identity.getUsername());
              log.info("username: #{identity.username}");
              log.info("password: #0", identity.getPassword());
              log.info("password: #{identity.password}");
              try {
                   User u = (User) entityManager.createQuery("select u from User u 
                                 where u.phoneNumber=#{identity.username} and
              catch (Exception e) {
                   log.info("Authentication failed");
                   return false;
              return true;

      the result:

      00:53:09,818 INFO  [AuthenticatorAction] username: test
      00:53:09,818 INFO  [AuthenticatorAction] username: test
      00:53:09,818 INFO  [AuthenticatorAction] password: testpass
      00:53:09,819 INFO  [AuthenticatorAction] password: testpass
      00:53:09,821 INFO  [STDOUT] Hibernate: 
              user0_.id as id28_,
              user0_.password as password28_,
              user0_.fullName as fullName28_,
              user0_.phoneNumber as phoneNum4_28_ 
              User user0_ 
              and user0_.password=?
      00:53:09,835 INFO  [AuthenticatorAction] Authentication failed

      As you can see, log.info("username: #{identity.username}"); gets resolved, but not in the query. What am I missing?