hibernate - How to reduce flush when using native queries in spring-data-japa? -


i working on project using spring 4.2 , hibernate 4.3.

by profiling, found repository methods @org.springframework.data.jpa.repository.query(nativequery=true) takes time. because org.hibernate.pa.internal.queryimpl.getresultlist() calls javax.persistence.entitymanager.flush() internally, regardless flush-mode use. flush() takes time if lot of entity in persistence context.

i think can avoided calling org.hibernate.sqlquery.addsynchronizedentityclass(), don't know best way call addsynchronizedentityclass() using spring-data-jpa (or other way tell hibernate not flush.)

what best practice reduce flush?

you can set flush mode commit desired (or all) sessions. keep in mind manually flush session if query depends on dirty session state.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -