ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Lemekhov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IGNITE-3235) Failed to initialize primitive boolean cache property of superclass
Date Mon, 06 Jun 2016 13:59:20 GMT

    [ https://issues.apache.org/jira/browse/IGNITE-3235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15316519#comment-15316519

Sergey Lemekhov commented on IGNITE-3235:

Anton, currently there are three ways of creating {{ClassProperty}} in {{GridQueryProcessor#buildClassProperty}}
* using {{java.lang.Class#getMethod}} with a string "get" + propertyName as argument
* if it fails then {{java.lang.Class#getDeclaredField}} with propertyName as argument
* if it fails then {{java.lang.Class#getMethod}} with propertyName as argument is used

The first approach doesn't work if the field accessor name doesn't start with 'get' ('is'
for instance) because this prefix is the only hardcoded option, and the second approach doesn't
work for fields in superclass. The third one doesn't work if there is no method with the same
name as field. Therefore there are two ways to fixing this as well - either try 'is' prefix
for boolean fields (for the first approach) or try calling {{getDeclaredField}} on the superclass.
So the fix you made works.

> Failed to initialize primitive boolean cache property of superclass
> -------------------------------------------------------------------
>                 Key: IGNITE-3235
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3235
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 1.5.0.final
>            Reporter: Sergey Lemekhov
>            Assignee: Anton Vinogradov
>            Priority: Minor
>             Fix For: 1.7
> When a superclass of a cache class contains a primitive boolean field marked with {{@QuerySqlField}}
annotation the cache initialization fails with an exception:
> {{org.apache.ignite.IgniteCheckedException: Failed to initialize property '<propertyName>'
for key class '<key class>' and value class 'value class'. Make sure that one of these
classes contains respective getter method or field.}}
> For example:
> {code}
> public class Base {
>        @QuerySqlField
>         private boolean flag;
>         public boolean isFlag() {
>             return flag;
>         }
>         public void setFlag(boolean flag) {
>             this.flag = flag;
>         }
>     }
> public class Derived extends Base {
>         private String field;
>         public String getField() {
>             return field;
>         }
>         public void setField(String field) {
>             this.field = field;
>         }
>     }
> {code}
> This related to method {{org.apache.ignite.internal.processors.query.GridQueryProcessor#buildClassProperty(boolean,
java.lang.Class<?>, java.lang.String, java.lang.Class<?>, java.util.Map<java.lang.String,java.lang.String>,
> Method expects that all fields accessors start with "get" but for primitive boolean fields
usually the "is" prefix is used.

This message was sent by Atlassian JIRA

View raw message