[hibernate-dev] Hibernate assumes arguments in HQL query where there are none
Marcel Stör
marcel at frightanic.com
Sun Jun 26 05:13:37 EDT 2011
I tried debugging the warning "Function template anticipated 3
arguments, but 2 arguments encountered" in TemplateRenderer. However, I
still don't understand what's actually going on...
The following uses an HQL query because there seems to be no
string-to-int conversion in JPQL (resorting to HQL cast):
public Set<Long> findImageVariantIdsWithOutOfBoundsDimension() {
final StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("select id from ImageVariant where ");
// imageVariantType is something like R_110X75 with 110 being max x.
// cast(substring( extracts 110.
queryBuilder.append("dimensionX > cast(substring(imageVariantType, 3,
locate('X', imageVariantType) - 3), int) ");
queryBuilder.append("or ");
// imageVariantType is something like R_110X75 with 75 being max y.
// cast(substring( extracts 75.
queryBuilder.append("dimensionY > cast(substring(imageVariantType,
locate('X', imageVariantType) + 1), int)");
final Query query =
getEntityManager().createQuery(queryBuilder.toString());
@SuppressWarnings("unchecked")
final Set<Long> result = new HashSet<Long>(query.getResultList());
return result;
}
I checked TemplateRenderer's internal argument list which contains ['X',
imagevaria0_.imagevarianttype]. I'm totally puzzled.
Cheers,
Marcel
--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the hibernate-dev
mailing list