protected void setNullPropertyValue(Entity entity, MetaProperty property) { // Using reflective access to field because the attribute can be unfetched if loading not partial entities, // which is the case when in-memory constraints exist Range range = property.getRange(); if (range.isClass()) { Object nullValue = null; if (range.getCardinality().isMany()) { Class<?> propertyType = property.getJavaType(); if (List.class.isAssignableFrom(propertyType)) { nullValue = new ArrayList<>(); } else if (Set.class.isAssignableFrom(propertyType)) { nullValue = new LinkedHashSet<>(); } } BaseEntityInternalAccess.setValue(entity, property.getName(), nullValue); BaseEntityInternalAccess.setValueForHolder(entity, property.getName(), nullValue); } else { BaseEntityInternalAccess.setValue(entity, property.getName(), null); } }
@Override public void visit(Entity entity, MetaProperty property) { MetaClass metaClass = metadata.getClassNN(entity.getClass()); if (!security.isEntityAttrReadPermitted(metaClass, property.getName())) { addInaccessibleAttribute((BaseGenericIdEntity) entity, property.getName()); if (!metadataTools.isSystem(property) && !property.isReadOnly()) { // Using reflective access to field because the attribute can be unfetched if loading not partial entities, // which is the case when in-memory constraints exist BaseEntityInternalAccess.setValue(entity, property.getName(), null); } } SecurityState securityState = BaseEntityInternalAccess.getSecurityState(entity); if (securityState != null && securityState.getHiddenAttributes().contains(property.getName())) { if (!metadataTools.isSystem(property)) { // Using reflective access to field because the attribute can be unfetched if loading not partial entities, // which is the case when in-memory constraints exist BaseEntityInternalAccess.setValue(entity, property.getName(), null); } } } }