public PropertyConfig getPropertyConfig(PersistentProperty property) { return (PropertyConfig) property.getMapping().getMappedForm(); }
protected boolean isIndexed(PersistentProperty property) { PropertyMapping<Property> pm = property.getMapping(); final Property keyValue = pm.getMappedForm(); return keyValue != null && keyValue.isIndex(); }
protected boolean isAssignedId(PersistentEntity persistentEntity) { boolean assignedId = false; PersistentProperty identity = persistentEntity.getIdentity(); if(identity != null) { PropertyMapping mapping = identity.getMapping(); if (mapping != null) { Property p = mapping.getMappedForm(); assignedId = p != null && "assigned".equals(p.getGenerator()); } } return assignedId; }
protected boolean isConstrainableProperty(PersistentProperty persistentProperty, String propertyName) { if(persistentProperty == null) { return NameUtils.isNotConfigurational(propertyName); } else { return !propertyName.equals(GormProperties.VERSION) && !propertyName.equals(GormProperties.DATE_CREATED) && !propertyName.equals(GormProperties.LAST_UPDATED) && !(persistentProperty instanceof Identity) && !(persistentProperty.getMapping().getMappedForm().isDerived()) && !( (persistentProperty instanceof ToOne) && ((ToOne)persistentProperty).isBidirectional() && ((ToOne) persistentProperty).isCircular()); } }
public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
protected String getPropertyKey(PersistentProperty prop) { PropertyMapping<Property> pm = prop.getMapping(); Property mappedProperty = pm.getMappedForm(); String key = null; if (mappedProperty != null) { key = mappedProperty.getTargetName(); } if (key == null) key = prop.getName(); return key; }
/** * Obtain the fetch strategy for the given property * * @param property The fetch strategy * @return A specific strategy or lazy by default */ protected FetchType fetchStrategy(String property) { final FetchType fetchType = fetchStrategies.get(property); if(fetchType != null) { return fetchType; } else { final PersistentProperty prop = entity.getPropertyByName(property); if(prop != null) { return prop.getMapping().getMappedForm().getFetchStrategy(); } } return FetchType.LAZY; }
public Property getMappedForm() { return classMapping.getEntity().getIdentity().getMapping().getMappedForm(); } };
@Override protected String getNativePropertyKey(PersistentProperty prop) { PropertyMapping<KeyValue> pm = prop.getMapping(); String propKey = null; if (pm.getMappedForm()!=null) { propKey = pm.getMappedForm().getKey(); } if (propKey == null) { propKey = prop.getName(); } return propKey; }
protected String getNativePropertyKey(PersistentProperty prop) { PropertyMapping<Property> pm = prop.getMapping(); String propKey = null; if (pm.getMappedForm()!=null) { propKey = pm.getMappedForm().getTargetName(); } if (propKey == null) { propKey = prop.getName(); } return propKey; }
public String[] getIdentifierName() { PersistentProperty identity = classMapping.getEntity().getIdentity(); String propertyName = identity != null ? identity.getMapping().getMappedForm().getName() : null; if(propertyName != null) { return new String[] { propertyName }; } else { return new String[] { IDENTITY_PROPERTY }; } }
public static String getTargetKey(PersistentProperty property) { PropertyMapping<Property> mapping = property.getMapping(); String targetName; if (mapping != null && mapping.getMappedForm() != null) { String tmp = mapping.getMappedForm().getTargetName(); targetName = tmp != null ? tmp : property.getName(); } else { targetName = property.getName(); } return targetName; }
/** * Interrogates the specified constraints looking for any constraints that would limit the * length of the property's value. If such constraints exist, this method adjusts the length * of the column accordingly. * @param column the column that corresponds to the property * @param constrainedProperty the property's constraints */ protected void bindStringColumnConstraints(Column column, PersistentProperty constrainedProperty) { final org.grails.datastore.mapping.config.Property mappedForm = constrainedProperty.getMapping().getMappedForm(); Number columnLength = mappedForm.getMaxSize(); List<?> inListValues = mappedForm.getInList(); if (columnLength != null) { column.setLength(columnLength.intValue()); } else if (inListValues != null) { column.setLength(getMaxSize(inListValues)); } }
final String targetName = persistentProperty.getMapping().getMappedForm().getTargetName(); if(targetName != null) { mappedPropertiesByName.put(targetName, persistentProperty);
Property mappedForm = p.getMapping().getMappedForm(); PersistentProperty version = entity.getVersion(); if (canPropertyBeConstrained(p) && !p.equals(version)) {
PropertyConfig constrainedProperty = (PropertyConfig) property.getMapping().getMappedForm(); if( cc != null && cc.getScale() > - 1) { column.setScale(cc.getScale());
protected void bindColumnConfigToColumn(PersistentProperty property, Column column, ColumnConfig columnConfig) { final PropertyConfig mappedForm = property != null ? (PropertyConfig) property.getMapping().getMappedForm() : null; boolean allowUnique = mappedForm != null && !mappedForm.isUniqueWithinGroup(); if (columnConfig == null) { return; } if (columnConfig.getLength() != -1) { column.setLength(columnConfig.getLength()); } if (columnConfig.getPrecision() != -1) { column.setPrecision(columnConfig.getPrecision()); } if (columnConfig.getScale() != -1) { column.setScale(columnConfig.getScale()); } if (columnConfig.getSqlType() != null && !columnConfig.getSqlType().isEmpty()) { column.setSqlType(columnConfig.getSqlType()); } if(allowUnique) { column.setUnique(columnConfig.getUnique()); } }
String path, PropertyConfig propertyConfig, String sessionFactoryBeanName) { setTypeForPropertyConfig(grailsProp, simpleValue, propertyConfig); final PropertyConfig mappedForm = (PropertyConfig) grailsProp.getMapping().getMappedForm(); if (mappedForm.isDerived() && !(grailsProp instanceof TenantId)) { Formula formula = new Formula();
protected String getDefaultColumnName(PersistentProperty property, String sessionFactoryBeanName) { NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName); String columnName = namingStrategy.propertyToColumnName(property.getName()); if (property instanceof Association) { Association association = (Association) property; boolean isBasic = property instanceof Basic; if(isBasic && ((PropertyConfig)property.getMapping().getMappedForm()).getType() != null ) { return columnName; } if (isBasic) { return getForeignKeyForPropertyDomainClass(property, sessionFactoryBeanName); } if (property instanceof ManyToMany) { return getForeignKeyForPropertyDomainClass(property, sessionFactoryBeanName); } if (!association.isBidirectional() && association instanceof org.grails.datastore.mapping.model.types.OneToMany) { String prefix = namingStrategy.classToTableName(property.getOwner().getName()); return addUnderscore(prefix, columnName) + FOREIGN_KEY_SUFFIX; } if (property.isInherited() && isBidirectionalManyToOne(property)) { return namingStrategy.propertyToColumnName(property.getOwner().getName()) + '_'+ columnName + FOREIGN_KEY_SUFFIX; } return columnName + FOREIGN_KEY_SUFFIX; } return columnName; }
grailsProperty.getMapping().getMappedForm().getAccessType() ); prop.setPropertyAccessorName( accessType.getType() );