I have an sql query as follows:
List employees = getCurrentSession()
.createSQLQuery(
\"select\"
For a simpler solution, double-quote the identifier in the query as sent to the server. Instead of
e.first_name as firstName
it should read
e.first_name as "firstName"
In PostgreSQL, double-quoting an identifier forces case-sensitivity. Unquoted, it (mostly) follows the SQL standard and folds to a single case (albeit lower case where the standard is upper case).
You can use addScalar(String columnAlias, Type type) to explicitly declare the column alias of your native SQL:
getCurrentSession()
.createSQLQuery( "select e.id as id,e.first_name as firstName,e.password as password from xxxxxx")
.addScalar("id",StandardBasicTypes.INTEGER )
.addScalar("firstName",StandardBasicTypes.STRING )
.addScalar("password",StandardBasicTypes.STRING )
.setResultTransformer(Transformers.aliasToBean(Employee.class))
.list();
It might be related to how ( and if ) you configured your NamingStrategy
http://matthew.mceachen.us/blog/hibernate-naming-strategies-20.html
or
if you're using MySQL to weather or not you've enabled case sensitive table/column names http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html