java - Regarding hibernate caching -


here scenario:

i select records database, 1000 records. operations on result set, insert 1 more record in or update existing record.

the entire above mentioned process repeat multiple times, 2000 times. (i.e. again select records, need not same records every time)

i sure can use sort of caching better performance. don't know how. can guide me?

when use hibernate, using 2 caches. first session cache. let's query 2000 records, update , save changes 5, , run same query again (all in scope of single session). hibernate not run query second time - knows have 2000 records (and 5 edits) loaded memory. cache turned on automatically - can't turn off, it's part of hibernate's core functionality. need close (or @ least flush) session ensure changes applied - don't want open 1 giant session , keep changing things or run out of memory.

the second level cache puts key-value store in between application , database. cache longer-lived, , multiple sessions can use it, it's more complex (e.g. needs deal threading, invalidation, etc). biggest problem if data changing lot, have make changes both in second level cache , database, can slower making changes directly. second level cache fantastic read-only data, however.

tuning hibernate , caches can quite challenging , complex. highly recommend use of tool such p6spy see database traffic between application , database.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -