@java.lang.SuppressWarnings({"rawtypes", "unchecked"}) public class GormMappingConfigurationStrategy extends java.lang.Object implements MappingConfigurationStrategy
This implementation of the MappingConfigurationStrategy interface will interpret GORM-style syntax for defining entities and associations.
Example in Groovy code:
class Author {
String name
static hasMany = [books:Book]
}
class Book {
String title
static belongsTo = [author:Author]
}
Modifiers | Name | Description |
---|---|---|
private static java.util.Set |
EXCLUDED_PROPERTIES |
|
private static java.lang.String |
IDENTITY_PROPERTY |
|
static java.lang.String |
MAPPED_BY_NONE |
|
private static java.lang.String |
VERSION_PROPERTY |
|
private boolean |
canExpandMappingContext |
|
protected MappingFactory |
propertyFactory |
Constructor and description |
---|
GormMappingConfigurationStrategy
(MappingFactory propertyFactory) |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
configureOwningSide(Association association) |
|
private ToOne |
establishDomainClassRelationship(PersistentEntity entity, java.beans.PropertyDescriptor property, MappingContext context, java.util.Map hasOneMap, boolean embedded) Establish relationship with related domain class |
|
protected Association |
establishRelationshipForCollection(java.beans.PropertyDescriptor property, PersistentEntity entity, MappingContext context, java.util.Map<java.lang.String, java.lang.Class> hasManyMap, java.util.Map mappedByMap, boolean embedded) |
|
private java.util.Set |
establishRelationshipOwners(ClassPropertyFetcher cpf) Evaluates the belongsTo property to find out who owns who |
|
private java.lang.String |
findManyRelatedClassPropertyName(java.lang.String propertyName, ClassPropertyFetcher cpf, java.util.Map classRelationships, java.lang.Class<?> classType) |
|
private java.lang.String |
findOneToManyThatMatchesType(PersistentEntity entity, java.beans.PropertyDescriptor pd, java.util.Map relatedClassRelationships, java.util.Map mappedBy, ClassPropertyFetcher relatedCpf) |
|
private java.beans.PropertyDescriptor |
findProperty(java.util.List<java.beans.PropertyDescriptor> descriptors, java.lang.String propertyName) Finds a property type is an array of descriptors for the given property name |
|
private boolean |
forceUnidirectional(java.beans.PropertyDescriptor property, java.util.Map mappedBy) check if mappedBy is set explicitly to null for the given property. |
|
protected java.util.Map |
getAllAssociationMap(ClassPropertyFetcher cpf) Retrieves the association map |
|
public java.util.Map |
getAssociationMap(ClassPropertyFetcher cpf) Retrieves the association map |
|
private java.util.Map |
getAssociationMap(ClassPropertyFetcher cpf, java.lang.String relationshipType) |
|
private java.util.List |
getCollectionStaticProperty(ClassPropertyFetcher cpf, java.lang.String property) |
|
public PersistentProperty[] |
getCompositeIdentity(java.lang.Class javaClass, MappingContext context) |
|
public IdentityMapping |
getDefaultIdentityMapping(ClassMapping classMapping) |
|
public PersistentProperty |
getIdentity(java.lang.Class javaClass, MappingContext context) |
|
public IdentityMapping |
getIdentityMapping(ClassMapping classMapping) Obtains the identity mapping for the specified class mapping |
|
private java.util.Map |
getMapStaticProperty(ClassPropertyFetcher cpf, java.lang.String property) |
|
protected PersistentEntity |
getOrCreateAssociatedEntity(PersistentEntity entity, MappingContext context, java.lang.Class propType) Tries to obtain or create an associated entity. |
|
protected PersistentEntity |
getOrCreateEmbeddedEntity(PersistentEntity entity, MappingContext context, java.lang.Class type) Tries to obtain or create an embedded entity. |
|
public java.util.Set |
getOwningEntities(java.lang.Class javaClass, MappingContext context) |
|
private PersistentEntity |
getPersistentEntity(java.lang.Class javaClass, MappingContext context, ClassMapping classMapping) |
|
public java.util.List<PersistentProperty> |
getPersistentProperties(java.lang.Class javaClass, MappingContext context) |
|
public java.util.List<PersistentProperty> |
getPersistentProperties(java.lang.Class javaClass, MappingContext context, ClassMapping classMapping) |
|
public java.util.List<PersistentProperty> |
getPersistentProperties(PersistentEntity entity, MappingContext context, ClassMapping classMapping, boolean includeIdentifiers) |
|
public java.util.List<PersistentProperty> |
getPersistentProperties(PersistentEntity entity, MappingContext context, ClassMapping classMapping) |
|
private java.util.List<java.beans.PropertyDescriptor> |
getPropertiesAssignableFromType(java.lang.Class type, ClassPropertyFetcher propertyFetcher) |
|
public static boolean |
isAbstract(PersistentEntity entity) |
|
protected boolean |
isCollectionType(java.lang.Class type) |
|
private boolean |
isExcludeId(java.lang.String propertyName, IdentityMapping id, java.lang.String[] identifierName, boolean includeIdentifiers) |
|
protected boolean |
isExcludedProperty(java.lang.String propertyName, ClassMapping classMapping, java.util.Collection transients, boolean includeIdentifiers) |
|
private boolean |
isIdentifierProperty(java.lang.String propertyName, java.lang.String[] identifierName) |
|
private boolean |
isNotMappedToDifferentProperty(java.beans.PropertyDescriptor property, java.lang.String relatedClassPropertyName, java.util.Map mappedBy) |
|
public boolean |
isPersistentEntity(java.lang.Class clazz) Tests whether an class is a persistent entity |
|
private boolean |
isRelationshipToMany(PersistentEntity entity, java.lang.Class<?> relatedClassType, java.util.Map relatedClassRelationships) Find out if the relationship is a 1-to-many or many-to-many. |
|
public void |
setCanExpandMappingContext(boolean canExpandMappingContext) Whether the strategy can add new entities to the mapping context |
|
protected boolean |
supportsCustomType(java.lang.Class<?> propertyType) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Establish relationship with related domain class
property
- Establishes a relationship between this class and the domain class propertyEvaluates the belongsTo property to find out who owns who
Finds a property type is an array of descriptors for the given property name
descriptors
- The descriptorspropertyName
- The property namecheck if mappedBy is set explicitly to null for the given property.
Retrieves the association map
cpf
- The ClassPropertyFetcher instanceRetrieves the association map
cpf
- The ClassPropertyFetcher instance
Obtains the identity mapping for the specified class mapping
classMapping
- The class mappingTries to obtain or create an associated entity. Note that if #canExpandMappingContext is set to false then this method may return null
entity
- The main entitycontext
- The contextpropType
- The associated property typeTries to obtain or create an embedded entity. Note that if #canExpandMappingContext is set to false then this method may return null
entity
- The main entitycontext
- The contexttype
- The associated property typeTests whether an class is a persistent entity Based on the same method in Grails core within the DomainClassArtefactHandler class
clazz
- The java classFind out if the relationship is a 1-to-many or many-to-many.
relatedClassType
- The related typerelatedClassRelationships
- The related types relationshipstrue
if the relationship is a many-to-manyWhether the strategy can add new entities to the mapping context