3

I have made the following replacements to upgrade my applications and plugins to grails 3.3. (the variable name change is due to improve clarity of the replacements.)

Grails 3.2:

Class<?> clazz = grailsDomainClass.clazz
...

def grailsDomainClass = new DefaultGrailsDomainClass(clazz)
...

GrailsDomainClassProperty[] properties = grailsDomainClass.properties
...

def propertyName = grailsDomainClass.propertyName
...

def referenceType = grailsDomainClassProperty.referencedPropertyType
...

Grails 3.3:

Class<?> clazz = persistentEntity.javaClass
...

def persistentEntity = grailsApplication.mappingContext.getPersistentEntity(DomainClass.class.name)
...

PersistentProperty[] properties = persistentEntity.persistentProperties
...

def propertyName = persistentEntity.decapitalizedName
...

def referenceType = persistentProperty.type

The other changes are at Grails 3.3 man.

Witch is not clear is:

  1. What is the replacement for:

    grailsDomainClass.getPropertyValue(propertyName)
    
  2. Where do I put the code which is in doWithSpring on my plugins?

The man page says:

The solution is to move any logic that executes before the context is available to somewhere else that executes after the context is available.

Somewhere else were? Is there a doWithContext closure? It can be used to inject bean?

1 Answers1

3
  1. Use the ClassPropertyFetcher.getPropertyValue method

  2. doWithApplicationContext is a method available to override for plugins where you can put your logic.

James Kleeh
  • 12,094
  • 5
  • 34
  • 61
  • in grails datastore 6.0.9 `org.grails.datastore.mapping.reflect.ClassPropertyFetcher` could return non static property value. But in 6.1.6 only static property value can be extracted. What changed? – Mamun Sardar Sep 05 '17 at 14:30