Sequence of flush(); clear(); commit(); can lead to LazyInitializationException

Description

I have a discriminator that throws a lazyloading exception in some cases:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 public class LanguageDiscriminator implements Discriminator { private static final Log log = LogFactory.getLog(LanguageDiscriminator.class); @Override public String getAnalyzerDefinitionName( Object value, Object entity, String field) { CountrySite cs = (CountrySite) value; if(cs != null) return cs.getCountry().getDefaultLanguage().getLanguageCode(); //BOOM log.warn("LanguageDiscriminator: No countrySite found, using Portugese "); return "pt"; } }

I'm trying to isolate the condition, but I wanted to note this here.

Environment

None

Status

Assignee

Fabio Massimo Ercoli

Reporter

Marc Schipperheyn

Labels

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

4.3.0.Final

Priority

Major