org.springframework.datastore.mapping.config
Class GormMappingConfigurationStrategy

java.lang.Object
  extended by org.springframework.datastore.mapping.config.GormMappingConfigurationStrategy
All Implemented Interfaces:
MappingConfigurationStrategy

public class GormMappingConfigurationStrategy
extends 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]
        }
  

 

Since:
1.0

Constructor Summary
GormMappingConfigurationStrategy(MappingFactory propertyFactory)
           
 
Method Summary
protected  Map getAssociationMap(ClassPropertyFetcher cpf)
          Retrieves the association map
 IdentityMapping getDefaultIdentityMapping(ClassMapping classMapping)
          Obtains the default manner in which identifiers are mapped.
 PersistentProperty getIdentity(Class javaClass, MappingContext context)
          Obtains the identity of a persistent entity
 Set getOwningEntities(Class javaClass, MappingContext context)
          Returns a set of entities that "own" the given entity.
 List<PersistentProperty> getPersistentProperties(Class javaClass, MappingContext context)
           
 List<PersistentProperty> getPersistentProperties(Class javaClass, MappingContext context, ClassMapping classMapping)
          Obtains a List of PersistentProperty instances for the given Mapped class
 boolean isPersistentEntity(Class clazz)
          Tests whether an class is a persistent entity Based on the same method in Grails core within the DomainClassArtefactHandler class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GormMappingConfigurationStrategy

public GormMappingConfigurationStrategy(MappingFactory propertyFactory)
Method Detail

isPersistentEntity

public boolean isPersistentEntity(Class clazz)
Tests whether an class is a persistent entity Based on the same method in Grails core within the DomainClassArtefactHandler class

Specified by:
isPersistentEntity in interface MappingConfigurationStrategy
Parameters:
clazz - The java class
Returns:
True if it is a persistent entity

getPersistentProperties

public List<PersistentProperty> getPersistentProperties(Class javaClass,
                                                        MappingContext context)
Specified by:
getPersistentProperties in interface MappingConfigurationStrategy
See Also:
MappingConfigurationStrategy.getPersistentProperties(Class, MappingContext, ClassMapping)

getPersistentProperties

public List<PersistentProperty> getPersistentProperties(Class javaClass,
                                                        MappingContext context,
                                                        ClassMapping classMapping)
Description copied from interface: MappingConfigurationStrategy
Obtains a List of PersistentProperty instances for the given Mapped class

Specified by:
getPersistentProperties in interface MappingConfigurationStrategy
Parameters:
javaClass - The Java class
context - The MappingContext instance
classMapping - The mapping for this class
Returns:
The PersistentProperty instances

getAssociationMap

protected Map getAssociationMap(ClassPropertyFetcher cpf)
Retrieves the association map

Parameters:
cpf - The ClassPropertyFetcher instance
Returns:
The association map

getOwningEntities

public Set getOwningEntities(Class javaClass,
                             MappingContext context)
Description copied from interface: MappingConfigurationStrategy
Returns a set of entities that "own" the given entity. Ownership dictates default cascade strategies. So if entity A owns entity B then saves, updates and deletes will cascade from A to B

Specified by:
getOwningEntities in interface MappingConfigurationStrategy
Parameters:
javaClass - The Java class
context - The MappingContext
Returns:
A Set of owning classes

getIdentity

public PersistentProperty getIdentity(Class javaClass,
                                      MappingContext context)
Description copied from interface: MappingConfigurationStrategy
Obtains the identity of a persistent entity

Specified by:
getIdentity in interface MappingConfigurationStrategy
Parameters:
javaClass - The Java class
context - The MappingContext
Returns:
A PersistentProperty instance
See Also:
MappingConfigurationStrategy.getIdentity(Class, org.springframework.datastore.mapping.MappingContext)

getDefaultIdentityMapping

public IdentityMapping getDefaultIdentityMapping(ClassMapping classMapping)
Description copied from interface: MappingConfigurationStrategy
Obtains the default manner in which identifiers are mapped. In GORM this is just using a property called 'id', but in other frameworks this may differ. For example JPA expects an annotated @Id property

Specified by:
getDefaultIdentityMapping in interface MappingConfigurationStrategy
Parameters:
classMapping - The ClassMapping instance
Returns:
The default identifier mapping