ignite icon indicating copy to clipboard operation
ignite copied to clipboard

No limit embedded field name support

Open junphine opened this issue 7 months ago • 0 comments

By default, Ignite will report an error if the Values entity is an embedded structure and the embedded field name is the same as the parent field name.

However, it seems that by making the following two small changes, embedded fields of any name can be supported.

class QueryEntityTypeDescriptor{

   /**
     * Adds property to the type descriptor.
     *
     * @param prop Property.
     * @param sqlAnn SQL annotation, can be {@code null}.
     * @param key Property ownership flag (key or not).
     * @param failOnDuplicate Fail on duplicate flag.
     */
    public void addProperty(QueryEntityClassProperty prop, QuerySqlField sqlAnn, boolean key, boolean failOnDuplicate) {
        String propName = **prop.fullName();** // modify here

        if (sqlAnn != null && !F.isEmpty(sqlAnn.name()))
            propName = sqlAnn.name();

        if (props.put(propName, prop) != null && failOnDuplicate) {
            throw new CacheException("Property with name '" + propName + "' already exists for " +
                (key ? "key" : "value") + ": " +
                "QueryEntity [key=" + keyCls.getName() + ", value=" + valCls.getName() + ']');
        }

        fields.put(propName, prop.type());

        if (key)
            keyProps.add(propName);
    }

}

QueryEntityClassProperty{
  /**
     * @return Alias.
     */
    public String alias() {
    	// modify
    	return F.isEmpty(alias) ? **fullName()** : alias;       
    }
}

junphine avatar May 15 '25 09:05 junphine