GridGain Community Edition

Expand all | Collapse all

Same field names on different classes throws CacheException

  • 1.  Same field names on different classes throws CacheException

    Posted 07-02-2020 12:36 PM

    Hi,
    On line 168 of the QueryEntityTypeDescriptor class the code was changed in how to compare the name of the property (prop.name()) against the list of known properties. This will result in problems with fields that have the same name.
    Example:

    Previous versions of this method would use prop.fullName() which solves this issue. According to this how can i solve the previous example without changing the field name? I even tried to change the name property on the @QuerySqlField annotation but without success.



    ------------------------------
    Nuno Ferreira
    IT Consultant
    Celfocus
    ------------------------------


  • 2.  RE: Same field names on different classes throws CacheException

    Posted 07-02-2020 08:51 PM
    Hi Nuno,

    This restriction was added because if key and value types of an SQL-enabled cache have the same fields annotated with `@QuerySqlEntity` the cache will start without errors, but the key's field will not be queryable: Checking why setting of names in annotation didn't help to resolve the conflict.

    ------------------------------
    Evgeniy Rudenko
    Programmer
    GridGain
    ------------------------------



  • 3.  RE: Same field names on different classes throws CacheException

    Posted 07-03-2020 07:24 AM
    Hi Evgeniy,

    First of all thanks for answering. According to the code the annotation fields are only processed after the addProperty method (the method where i get the exception from). So the properties that we add in the @QuerySqlField  annotation don't change anything prior to the addProperty method.

    ​And the name field from the @QuerySqlField  annotation​ doesn't change the name of the property. Instead sets the alias field with the given name.

    This code doesn´t makes sense to me because the name field specifically says: "Property name. If not provided then field name will be used." So for me makes sense that the processAnnotation function to be executed before the addProperty function. Maybe a wrong assumptions.

    Anyway hope to get an answer from you on how to solve this problem. Thanks again.

    ------------------------------
    Nuno Ferreira
    IT Consultant
    Celfocus
    ------------------------------



  • 4.  RE: Same field names on different classes throws CacheException

    Posted 07-03-2020 07:46 AM
    Yes, this is a bug and I am going to fix it. But the fix will be available only in the next Ignite release. For now I see only one workaround - give unique name for your fields.

    ------------------------------
    Evgeniy Rudenko
    Programmer
    GridGain
    ------------------------------