java - Hibernate filters with list parameter and with JPA -
i'm using jpa + hibernate 4.3.11 final. i'm trying use filters in query. part of bean:
@filterdefs({ @filterdef(name = "localitafilter", parameters = { @paramdef(name = "localita", type = "long") }) }) @filter(name = "localitafilter", condition = "localitaintervento_id in (:localita)") @entity public class segnalazione extends abstractentity implements serializable { private static final long serialversionuid = 1l;
and part of code when try apply filter collections of long values:
list<localita> listalocalitaautorizzate = operatorerepository.findlocalitaautorizzate(username); list<long> listaid = listalocalitaautorizzate.stream().map(l -> l.getid()).collect(collectors.tolist()); filter filtro = (filter) entitymanager.unwrap(session.class).enablefilter("localitafilter"); filtro.setparameterlist("localita", listaid); ...
unfortunately when run query i've exception:
org.hibernate.hibernateexception: undefined filter parameter [localita] @ org.hibernate.internal.filterimpl.setparameterlist(filterimpl.java:121) ~[hibernate-core-4.3.11.final.jar:4.3.11.final] @ it.segnalazionecustomrepositoryimpl.findbyfilter(segnalazionecustomrepositoryimpl.java:131) [classes/:?] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[?:1.8.0_112] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) ~[?:1.8.0_112] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[?:1.8.0_112] @ java.lang.reflect.method.invoke(method.java:498) ~[?:1.8.0_112] @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:302) [spring-aop-4.2.6.release.jar:4.2.6.release] @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) [spring-aop-4.2.6.release.jar:4.2.6.release] @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) [spring-aop-4.2.6.release.jar:4.2.6.release]
seems parameter not set; case see set.
i'm doing wrong?
Comments
Post a Comment