我正在尝试将Grails应用程序从1.0.3升级到1.3.7并遇到异常:
object references an unsaved transient instance - save the transient instance before flushing:
Run Code Online (Sandbox Code Playgroud)
我没有在触发的代码中进行任何保存.它在以下代码中
public static Season getCurrentSeason() {
String yearString = ConfigurationHolder.config.year
assert yearString != null: "need to configure season"
int year = Integer.parseInt(yearString)
Affiliation nfl = Affiliation.nfl;
return Season.findBySeasonKeyAndLeague(year, nfl)
}
Run Code Online (Sandbox Code Playgroud)
对Affiliation.nfl的调用是:
public static Affiliation getNfl() {
if (cacheNFL == null) {
String key = ConfigurationHolder.config.nfl
cacheNFL = Affiliation.findByKey(key)
}
return cacheNFL;
}
Run Code Online (Sandbox Code Playgroud)
如果我删除cacheNFL并使其每次都进行实际获取,则代码可以正常工作.我的问题是: