-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Binding parameter with filter defination default condition
PostPosted: Thu Jun 12, 2014 5:24 am 
Newbie

Joined: Wed Jun 11, 2014 4:09 pm
Posts: 1
Hi ,
My hibernate filter definition goes like :
Code:
@FilterDef(name="userTokenTypeFilter",defaultCondition="(ID in (SELECT user.TOKEN_ID from MY_TOKENS where user.ID=: userIndex)" parameters =@ParamDef(name="userIndex", type="string")


and using this filter to TOKENS entity and while enabling filter my code look like :
Code:
  hbSession.enableFilter("userTokenTypeFilter");
         Filter filter = hbSession.getEnabledFilter("userTokenTypeFilter");
         filter.setParameter("userIndex", String.valueOf(user.getIdInt()));


While filtering , generated query is look like :
Code:
SELECT * FROM  TOKENS this_ where (this_.ID in (SELECT user.TOKEN_ID from MY_TOKENS where user.ID=? this_.userIndex))



My component.xml :

Code:
<persistence:filter name="userTokenTypeFilter" enabled="#{Security.hasTokenRestriction}">
   <persistence:name>userTokenTypeFilter</persistence:name>
   <persistence:parameters>
      <key>userIndex</key>
      <value>#{InvoiceSecurity.userIndex}</value>
   </persistence:parameters>
   </persistence:filter>



I don't understand why "input_.userIndex" getting append to the above query as binding parameter. This cause NullPointerException at criteria.list() of package org.hibernate.search.engine.ObjectLoaderHelper initializeObjects method. Logs give me error in binding parameters. Please suggest.
Error Log:
Code:
java.lang.NullPointerException
   at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1732)
   at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1703)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.