Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Mark Spritzler wrote:
My bigger opinion is that I never use the HibernateTemplate because with the latest Hibernate's I get absolutely no benefit from the Spring HibernateTemplate. With that in mind, know that I used to work at SpringSource, and I highly recommend using Spring and their classes, but this is one that no longer is needed.
Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Leonardo Carreira wrote:
Mark Spritzler wrote:
My bigger opinion is that I never use the HibernateTemplate because with the latest Hibernate's I get absolutely no benefit from the Spring HibernateTemplate. With that in mind, know that I used to work at SpringSource, and I highly recommend using Spring and their classes, but this is one that no longer is needed.
Thanks Mark for your post reply first..
is it any another way to integrating Spring and Hibernate with not use HibernateTemplate?
if we develop an application based on Spring, what technology is good for The Persistence Layer?..
is it just use a Persistence Class which provided by Spring?..
iam sorry before, iam still newbie..
in my application i just use Spring for IoC and DAO layer..
maybe i think i will learn more about SpringMVC, and IoC..
Thanks in advance
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Kengkaj Sathianpantarit wrote:Mark, if you haven't used HibernateTemplate, how did you make data access code thread-safe?
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
NOTE: As of Hibernate 3.0.1, transactional Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate3 style of coding data access objects instead, based on SessionFactory.getCurrentSession().
I guess SessionFactory.getCurrentSession() handles thread-safe.It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.
Implementors must be threadsafe.
getCurrentSession()
throws HibernateException
Obtains the current session. The definition of what exactly "current" means controlled by the CurrentSessionContext impl configured for use.
Implementations should adhere to the following:
* contain a constructor accepting a single argument of type SessionFactoryImplementor
* should be thread safe
* should be fully serializable
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Mark Spritzler wrote:the HibernateTemplate was not created to solve any thread safety
Binds a Hibernate Session from the specified factory to the thread, potentially allowing for one thread-bound Session per factory. SessionFactoryUtils and HibernateTemplate are aware of thread-bound Sessions and participate in such transactions automatically. Using either of those or going through SessionFactory.getCurrentSession() is required for Hibernate access code that needs to support this transaction handling mechanism.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|