Can't initialize the transition element?

In grails 2.0.4, I have a domain class as follows:

class Foo { String pres String temp static transients = ['temp'] def beforeInsert = { println "pres: ${pres}" println "temp: ${temp}" } } 

In BootStrap.groovy:

 def f1 = new Foo(pres: "p1", temp: "t1") f1.save() def f2 = new Foo(pres: "p2") f2.temp = "t2" f2.save() 

Then grails run-app, I got:

 pres: p1 temp: null pres: p2 temp: t2 

What is the difference between f1 and f2, cannot initialize the transition element?

+6
source share
2 answers

I came across this same subject after switching to Grails 2. Check out these two JIRA entries if you want more information:

http://jira.grails.org/browse/GRAILS-8972

http://jira.grails.org/browse/GRAILS-9098

But, ultimately, I had to resort to the same work as in your example.

0
source

Source: https://habr.com/ru/post/918857/


All Articles