public void initialize() {
    if (domainClass.getIdentifier() != null) {
      identifier = new GrailsDomainClassPersistentProperty(this, domainClass.getIdentifier());
      propertiesByName.put(identifier.getName(), identifier);
    }
    if (domainClass.getVersion() != null) {
      version = new GrailsDomainClassPersistentProperty(this, domainClass.getVersion());
      propertiesByName.put(version.getName(), version);
    }

    mappingContext.addEntityValidator(this, domainClass.getValidator());

    final GrailsDomainClassProperty[] persistentProperties = domainClass.getPersistentProperties();
    for (GrailsDomainClassProperty grailsDomainClassProperty : persistentProperties) {
      PersistentProperty persistentProperty;
      if (grailsDomainClassProperty.isAssociation()) {
        if (grailsDomainClassProperty.isEmbedded()) {
          persistentProperty = createEmbedded(mappingContext, grailsDomainClassProperty);
        } else if (grailsDomainClassProperty.isOneToMany()) {
          persistentProperty = createOneToMany(mappingContext, grailsDomainClassProperty);
        } else if (grailsDomainClassProperty.isHasOne()) {
          persistentProperty = createOneToOne(mappingContext, grailsDomainClassProperty);
        } else if (grailsDomainClassProperty.isOneToOne()) {
          persistentProperty = createOneToOne(mappingContext, grailsDomainClassProperty);
        } else if (grailsDomainClassProperty.isManyToOne()) {
          persistentProperty = createManyToOne(mappingContext, grailsDomainClassProperty);
        } else if (grailsDomainClassProperty.isManyToMany()) {
          persistentProperty = createManyToMany(mappingContext, grailsDomainClassProperty);
        } else {
          persistentProperty =
              new GrailsDomainClassPersistentProperty(this, grailsDomainClassProperty);
        }
      } else if (grailsDomainClassProperty.isBasicCollectionType()) {
        persistentProperty = createBasicCollection(mappingContext, grailsDomainClassProperty);
      } else {
        persistentProperty =
            new GrailsDomainClassPersistentProperty(this, grailsDomainClassProperty);
      }
      propertiesByName.put(grailsDomainClassProperty.getName(), persistentProperty);
      properties.add(persistentProperty);

      if (persistentProperty instanceof Association) {
        associations.add((Association) persistentProperty);
      }
    }
    initialized = true;
  }
 public boolean isIdentityName(String propertyName) {
   return domainClass.getIdentifier().getName().equals(propertyName);
 }