I tried to setup a hibernate filter, enabled in components.xml, with a parameter.
I have tested 3 scenarii :
long, in the EL value in components.xml I inject a value of type Long : EL value result is always empty
longparameter, and
Stringas EL result value : exception
wrong type for parameter
stringas hibernte filter parameter and
Stringas EL result value : OK !
So I have 2 questions :
My components.xml code :
<persistence:filter name="hasRights" enabled="#{identity.loggedIn}"> <persistence:name>hasRights</persistence:name> <persistence:parameters> <key>companyId</key> <value>#{companyId}</value> </persistence:parameters> </persistence:filter> <persistence:managed-persistence-context name="restrictedEntityManager" auto-create="true" persistence-unit-jndi-name="java:/appEntityManagerFactory"> <persistence:filters> <value>#{hasRights}</value> </persistence:filters> </persistence:managed-persistence-context>
The definition of the filter :
@FilterDefs(value={ @FilterDef(name="hasRights", parameters={@ParamDef(type="string", name="companyId")}) })
The Filter :
@Filters(value={ @Filter( name="hasRights", condition="(company_id = :companyId)" ) })
Yeah, this might be a problem with Seam. File a feature request in JIRA.