Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade from grails 3.2 to grails 3.3, GrailsDomainClass Api Deprecated

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?

like image 647
wladimirguerra Avatar asked Nov 22 '25 22:11

wladimirguerra


1 Answers

  1. Use the ClassPropertyFetcher.getPropertyValue method

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

like image 195
James Kleeh Avatar answered Nov 28 '25 02:11

James Kleeh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!