CLI: issues using AlertDefinitionCriteria to filter results from AlertDefinitionManager query

Joseph Marques jmarques at redhat.com
Wed Apr 28 14:11:38 UTC 2010


On 04/28/2010 08:57 AM, Bala Nair wrote:
> Hi all,
>   I'm new to RHQ development and have run into an issue using the CLI 
> to test alert definition filtering.  I am able to get a list of all 
> alert defs returned from 
> AlertDefinitionManager.findAlertDefinitionsByCriteria(new 
> AlertDefinitionCriteria()), but when I try to set a condition in the 
> criteria I get an exception or an empty result set.  I traced the code 
> execution as far as the bolded line below - the call to 
> getSingleResult in CriteriaQueryRunner.execute() and then it drops 
> into hibernate code.  I'm not familiar with hibernate or how the 
> object mapping works between the AlertDefinitionCriteria members and 
> the filter overrides, but it strikes me as significant that I'm seeing 
> a cast exception when I try to filter by parent id which is an integer 
> in the db but a string in the AlertDefintionCriteria.  Any help would 
> be appreciated.  TIA.
>
> Bala Nair
>
> Filter by parent id:
>
> rhqadmin at 192.168.209.93:7780$ var c1 = new AlertDefinitionCriteria()
>
> rhqadmin at 192.168.209.93:7780$ c1.addFilterAlertTemplateParentId(0)
>
> rhqadmin at 192.168.209.93:7780$ 
> AlertDefinitionManager.findAlertDefinitionsByCriteria(c1)
>
> [Warning] javax.ejb.EJBException: java.lang.ClassCastException: 
> java.lang.String cannot be cast to java.lang.Integer
Bela, the issue is that AlertDefinitionCriteria was mapping that filter 
field to a String type, but it actually refers to an Integer in the 
underlying data model.  This issue was documented here[1] and I've 
already pushed a fix to master (git hash 
303467aeda8d90b48cb68581d53211c774a82fd5).  Thanks for finding this.

-joseph

[1] - https://bugzilla.redhat.com/show_bug.cgi?id=586918 
(AlertDefinitionCriteria throws ClassCastException if 
filterAlertTemplateParentId / filterAlertTemplateResourceTypeId is set)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://fedorahosted.org/pipermail/rhq-devel/attachments/20100428/e7d78ad1/attachment-0001.html 


More information about the rhq-devel mailing list