[jboss-jira] [JBoss JIRA] (DROOLS-31) RowAdapter should not throw Exception when Object not found

Davide Sottara (JIRA) jira-events at lists.jboss.org
Sun Sep 8 02:07:04 EDT 2013


    [ https://issues.jboss.org/browse/DROOLS-31?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12802589#comment-12802589 ] 

Davide Sottara commented on DROOLS-31:
--------------------------------------

You can use KnowledgeBase metadata to see queries and their parameters.. you can then create a "reflective" listener
This snippet of code finds all Queries in a KB and retrieves the (internal) descriptor which contains argument info:

        String packageName = "...";
        for ( org.drools.definition.rule.Query k : kbase.getKnowledgePackage( packageName ).getQueries() ) {
            org.drools.rule.Query q = (org.drools.rule.Query) kbase.getQuery( packageName, k.getName() );
            for ( Declaration decl : q.getParameters() ) {
                System.out.println( decl.getIdentifier() + " : " + decl.getTypeName() );
            }
        }

Knowing the parameters, the exception should still be raised in case something goes very wrong
                
> RowAdapter should not throw Exception when Object not found
> -----------------------------------------------------------
>
>                 Key: DROOLS-31
>                 URL: https://issues.jboss.org/browse/DROOLS-31
>             Project: Drools
>          Issue Type: Enhancement
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.5.0.Final
>            Reporter: Ryan Nideffer
>            Assignee: Mark Proctor
>
> RowAdapter throws an undocumented, unchecked exception if an identifier passed to get() does not exist as a row in the returned query.
> This pattern is not ideal, and instead should simply return null, thereby allowing clients to easily skip non-existent objects much more cleanly and more lightweight than exception handling.
> Additionally, the ViewChangedEventListener interface does not provide a way to know which query was invoked for the callback. It is cumbersome to create per-query ViewChangedEventListener objects which allows you to avoid querying identifiers that you know exist in the query result callback.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list