Search
Duplicate
โ˜•

findById ํ•˜๋ฉด ๋ฌด์Šจ ์ผ์ด ์ผ์–ด๋‚ ๊นŒ

์ฒ˜์Œ์ผ ๋•Œ

SessionImpl ์—์„œ fireLoad() ๋ฅผ ํ•œ๋‹ค.
fireLoad() ์—์„œ fireLoadNoChecks() ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.
fireLoadNoChecks() ์—์„œ fastSessionServices.eventListenerGroup_LOAD.fireEventOnEachListener( event, loadType, LoadEventListener::onLoad ); ๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.
fireEventOnEachListener() ๋Š” EventListenerGroupImpl ์˜ ๋ฉ”์„œ๋“œ์ด๊ณ , eventType ์€ load ์ด๋‹ค.
๋“ฑ๋ก๋œ listener ๋“ค์„ ํ™•์ธํ•˜๋Š”๋ฐ DefaultLoadEventListener ๋ฐ–์— ์—†๋‹ค.
LoadEventListener::onLoad ๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.
DefaultLoadEventListener
onLoad() ์—์„œ๋Š” persister(๋ฐ˜ํ™˜ ๊ฐ์ฒด) ๋ฅผ ์ฐพ๊ณ  doOnLoad() ํ˜ธ์ถœ
doOnLoad() ์—์„œ๋Š” persister ์™€ identifier ๋ฅผ ๊ฐ€์ง„ entityKey ๋ฅผ ์ฐพ๊ณ  proxyOrLoad() ํ˜ธ์ถœ
proxy ์ธ์ง€ ํ™•์ธํ•˜๊ณ  return a newly loaded object ์ด๋ฉด load() ๋ฅผ ํ˜ธ์ถœ
load() ์—์„œ doLoad() ํ˜ธ์ถœ
doLoad() ์—์„œ 1์ฐจ ์บ์‹œ(SessionCache), 2์ฐจ ์บ์‹œ(SecondLevelCache) ํ™•์ธ ํ›„ ์—†์œผ๋ฉด loadFromDatasource() ํ˜ธ์ถœ
loadFromDatasource() ์—์„œ persister.load() ์ˆ˜ํ–‰
AbstractEntityPersister
load() ์—์„œ doLoad() ์ˆ˜ํ–‰ โ†’ ๋‘ ๋ฉ”์„œ๋“œ ๋‹ค parameter ๋˜‘๊ฐ™์Œ;; ๊ทธ๋Ÿผ ์™œ load() ๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๊ฑฐ์ง€;;
getAppropriateLoader() ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ EntityLoader ์ฐพ๊ณ  EntityLoader ์—๊ฒŒ load() ํ˜ธ์ถœ
Abstract~~Loader
load() ์—์„œ QueryParameters ๊ฐ์ฒด ์ƒ์„ฑํ•˜๊ณ  executeLoad() ํ˜ธ์ถœ
executeLoad() ์—์„œ ์ผ๋‹จ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์˜ beforeLoad() ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด load count ๋ฅผ 1 ์ฆ๊ฐ€์‹œํ‚ด
sql ์ „์ฒ˜๋ฆฌํ•˜๊ณ  prepareQueryStatement() ํ˜ธ์ถœ
StatementPreparerImpl ์—์„œ preparedStatement ์ƒ์„ฑ
์ƒ์„ฑ๋œ ps ์— bind parameter ํ•จ
getResultSet() ํ˜ธ์ถœํ•˜๊ณ  ํ•ด๋‹น ๋ฉ”์„œ๋“œ์—์„œ extract() ํ˜ธ์ถœ
extract() ๋Š” ResultSetReturnImpl ์˜ ๋ฉ”์„œ๋“œ์ด๊ณ  ์—ฌ๊ธฐ์„œ ps ์˜ JdbcPreparedStatement ์˜ executeQuery() ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ!!
DefaultLoadEventListener ์˜ 67๋ฒˆ์ค„ primitive ๋ผ๋ฉด ์–ด๋–จ์ง€ ํ™•์ธ, 61๋ฒˆ getPersister() ํ™•์ธ

์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์— ์žˆ์„ ๋•Œ

DefaultLoadEventListener ์˜ doOnLoad() 1์ฐจ ์บ์‹œ(SessionCache) ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด
CacheEntityLoaderHelper.INSTANCE.loadFromSessionCache( event, keyToLoad, options ); ํ˜ธ์ถœ
loadFromSessionCache() ์—์„œ session.getEntityUsingInterceptor( keyToLoad ); ํ˜ธ์ถœ
getEntityUsingInterceptor() ์—์„œ persistenceContext.getEntity( key ); ํ˜ธ์ถœ key ๋Š” EntityKey ๊ฐ์ฒด
๊ทธ๋Ÿผ StatefulPersistenceContext ์˜ entitiesByKey(HashMap) ์—์„œ key ๋กœ ํ™•์ธ