java - how to fix this jpa/hibernate oracle error -
i use following code build query in jpa hibernate 4.1.9.final implementation:
if (!stringutils.isblank(filtertext)) { string search = "%" + request.getpaging().getfilter().getfiltertext().trim().tolowercase() + "%"; string datesearch = search; try { datesearch = "%" + datetimeformatutils.formatdateonlyfordb(filtertext) + "%"; } catch (illegalargumentexception exception) { // no-op, it's okay if filtertext not date } predicate textpredicate = criteriabuilder.or( buildlikepredicate(criteriabuilder, deposit, deposit_.id, search), buildlikepredicate(criteriabuilder, deposit, deposit_.date, datesearch), buildlikepredicate(criteriabuilder, deposit, deposit_.bankaccountnumber, search), buildlikepredicate(criteriabuilder, deposit, deposit_.amount, search), buildlikepredicate(criteriabuilder, merchant, merchant_.merchid, search), buildlikepredicate(criteriabuilder, merchant, merchant_.customname, search)); predicates.add(textpredicate); } return predicates.toarray(new predicate[predicates.size()]);
and code buildlikepredicate() is:
private <r, j> predicate buildlikepredicate( final criteriabuilder criteriabuilder, final from<r, j> from, final singularattribute<? super j, ?> column, final string searchtext) { return criteriabuilder.like(criteriabuilder.lower(from.get(column).as(string.class)), searchtext); }
basically i'm building bunch of 'likes' against different columns , column isn't string type cast string comparison purposes.
i run extensive integration tests against in-memory hsqldb , works expected.
however when run server against real oracle database, following:
java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: expecting close, found '(' near line 1, column 277 [select generatedalias0 entities.vdeposit generatedalias0 inner join generatedalias0.merchant generatedalias1 ( generatedalias1.customerid=100000 ) , ( generatedalias0.date>=:param0 ) , ( ( lower(cast(generatedalias0.id varchar2(255 char))) :param1 ) or ( lower(cast(generatedalias0.date varchar2(255 char))) :param2 ) or ( lower(generatedalias0.bankaccountnumber) :param3 ) or ( lower(cast(generatedalias0.amount varchar2(255 char))) :param4 ) or ( lower(generatedalias1.merchid) :param5 ) or ( lower(generatedalias1.customname) :param6 ) ) order generatedalias0.date desc]
it seems choke on:
cast(generatedalias0.id varchar2(255 char))
as being invalid syntax (note it's hql syntax, not yet sql)
is aware of there being hibernate/oracle bug when calling javax.persistence.criteria.expression.as()?
any ideas how fix this?
thanks!
update
this so question references same exact problem. ticket filed bug looks fixed in hibernate 3.6.10 , 4.1.0. using version 4.1.9.final , still seeing issue. bug reintroduced?
update
upgraded latest hibernate 4.3.6.final , still seeing same bug.
Comments
Post a Comment