title: SqlProjection - cannot use entity name and cannot use {alias} to compare
body: <p>I have a two part question.</p>
  
  <ol>
  <li>I am using Criteria and Projections to retrieve data. I am mapping the resultant data set to a DTO. I had to use SqlProjection to get some data, but it seems the sql projection does not accept the Entity name, but its table name in the DB.</li>
  </ol>
  
  <p>ie. I cannot use something like the following</p>
  
  <pre><code>.add(Projections.sqlProjection("(select count(c.someData) 
       from EntityName c where c.id= " + 
       passedID + ") as someDataField",  
       new String[] { "someDataField" }, 
       new Type[] { IntegerType.INSTANCE }))
  </code></pre>
  
  <p>but if I replace with the column names and tablename it works. Like so,</p>
  
  <pre><code>.add(Projections.sqlProjection("(select count(c.SOME_DATA_COLUMN) 
           from TABLE_NAME c where c.ID_COLUMN= " + 
           passedID + ") as someDataField",  
           new String[] { "someDataField" }, 
           new Type[] { IntegerType.INSTANCE }))
  </code></pre>
  
  <p>Why is this happening?</p>
  
  <ol start="2">
  <li>Also, I have an entity Entity which extends a class 'Auditable' which has a field 'createdBy'. Auditable includes fields which are common for almost all the tables like 'status of record', 'created by', 'date created' etc.</li>
  </ol>
  
  <p>I am trying to retrieve the data from Users entity which corresponds to USERS_TABLE.
  I have First_Name and Last_Name columns and User_ID, all Varchar, in the table and fields are in entity.</p>
  
  <p>Created_By column in every table refers to User_ID in USERS_TABLE.</p>
  
  <p>Now, I want to retrieve the first name and last name with the createdBy field.</p>
  
  <p>I wrote a sqlProjection along with other projections. It looks as follows.</p>
  
  <pre><code>.add(Projections.sqlProjection(
       "(select concat(user.First_Name, ' ', user.Last_Name) from USERS_TABLE user " 
                      + "where user.User_ID = {alias}.mappedParentEntity.createdBy) as createdBy",  
                       new String[] { "createdBy" }, 
                       new Type[] { StringType.INSTANCE }))
  </code></pre>
  
  <p>{alias} refers to the alias of root entity.</p>
  
  <p>I get an error which says </p>
  
  <blockquote>
    <p>Unknown column 'this_.mappedParentEntity.createdBy' in 'where clause'</p>
  </blockquote>
  
  <p>What could be the solution for this one?</p>