Criteria API drastically degrades performance

Description

Especially in multi-threaded in environments, the classloader is accessed way to often to convert the Criteria Query into SQL. In some containers like Tomcat we observed that the classloader is synchronized. This combination drastically degrades performance of our application servers.

see

http://dimovelev.blogspot.ch/2015/02/performance-pitfalls-hibernate-criteria.html

or

http://stackoverflow.com/questions/26608973/synchronized-classloader-calls-from-hibernate/37279205#37279205

or

https://hibernate.atlassian.net/browse/HHH-9895

which was closed without further information. The code in question:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Thread [main] (Suspended (breakpoint at line 191 in ReflectHelper)) owns: QueryTranslatorImpl (id=8378) ReflectHelper.classForName(String) line: 191 ReflectHelper.getConstantValue(String) line: 279 QueryTranslatorImpl$JavaConstantConverter.handleDotStructure(AST) line: 624 QueryTranslatorImpl$JavaConstantConverter.visit(AST) line: 619 NodeTraverser.visitDepthFirst(AST) line: 78 NodeTraverser.traverseDepthFirst(AST) line: 67 QueryTranslatorImpl.parse(boolean) line: 300 QueryTranslatorImpl.doCompile(Map, boolean, String) line: 203 QueryTranslatorImpl.compile(Map, boolean) line: 158 HQLQueryPlan.<init>(String, String, boolean, Map<String,Filter>, SessionFactoryImplementor, EntityGraphQueryHint) line: 131 HQLQueryPlan.<init>(String, boolean, Map<String,Filter>, SessionFactoryImplementor) line: 93 QueryPlanCache.getHQLQueryPlan(String, boolean, Map<String,Filter>) line: 167 SessionImpl(AbstractSessionImpl).getHQLQueryPlan(String, boolean) line: 301 SessionImpl(AbstractSessionImpl).createQuery(String) line: 236 SessionImpl.createQuery(String) line: 1800 EntityManagerImpl(AbstractEntityManagerImpl).createQuery(String, Class<T>, Selection, QueryOptions) line: 568 CriteriaQueryImpl$1.buildCompiledQuery(HibernateEntityManagerImplementor, InterpretedParameterMetadata) line: 336 CriteriaCompiler.compile(CompilableCriteria) line: 147 EntityManagerImpl(AbstractEntityManagerImpl).createQuery(CriteriaQuery<T>) line: 736 Activity

A solution/workaround for this problem is necssary.

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Remo Meier

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.1.0

Priority

Blocker
Configure