If there is a table "Entity" and you want to return only the name and ID fields(criteria.setProjection(<name> <id> fields) but ID is in a condition in search criteria ( Restrictions.eq("id", XXXXXX )) then hibernate generates this criteria: select this_.NAME as y0_, this_.ID as y1_ from Entity this_ where y1_=?
Either removing the search condition(restrictions) or removing from the project fields(i.e no result) can fix this problem since the column alias(y1_) show up only if a field exists in both places.
Postgres complains the y1_ column doesn't exist. According to some people's comments on postgres, the select statement is not processed before where statement is processed so the column alias is not known in where statement. This might conform to some SQL standard.
Is this a hibrenate library issue?
|