title: How to convert query object into a List of Strings?
body: <p>I got a Login class:</p>
  
  <pre><code>if((!(name.equals(null) || name.equals("")) &amp;&amp; !(password.equals(null) ||  password.equals(""))))
          {
              try{
                  loggedUser = checkLogin(name, hexPass.toString());
  
                  if(!loggedUser.isEmpty())
                  {
                      userdbId = loggedUser.get(0);
                      userdbName = loggedUser.get(1);
                      userdbPsw = loggedUser.get(2);
                      userdbType = loggedUser.get(3);
  
                      ...
  </code></pre>
  
  <p>And a user DAO:</p>
  
  <pre><code>public List&lt;String&gt; checkLogin(String uname, String password) {
      Session session = null;
      List&lt;String&gt; lst = new ArrayList&lt;String&gt;();
      try {
          session = getSession();
          String sql = "select * from user where uname='" + uname + "' and password='" + password + "'";
          Query query = session.createSQLQuery(sql)
                  .addScalar("Id", StringType.INSTANCE)
                  .addScalar("uname", StringType.INSTANCE) 
                  .addScalar("password", StringType.INSTANCE) 
                  .addScalar("utype", StringType.INSTANCE);
          lst = query.list();
      }
      catch (Exception e){
          e.printStackTrace();
      }
      return lst;
  }
  </code></pre>
  
  <p>The userdbId = loggedUser.get(0); generates error: 500</p>
  
  <pre><code>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.String
  com.se.pl.actions.LoginAction.execute(LoginAction.java:95)
  </code></pre>
  
  <p>I do not understand why this is happening since list of 4 strings is going to be put into 4 variables.</p>