Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Fetching data without transaction

Below is the sample code snippet with spring transaction . My question :-Will same session be used for fetching entities at line1 and line2 ?

My understanding :- I believe yes and it will be ensured by spring transaction

@Transactional()
    public void method1(
     //fetch entity1 from dao  with the help of entity manager//line 1

     // fetch entity2 from dao with the help of entity manager//line 2

    // now I fetch thru method entity.fetchLazyField()// line 3
    )

Now if i remove @Transactional(). I believe session will be closed as soon as entity1 is fetched and separate session will be used for line2. Right ?

At line 3(once @Transactional is removed) , will I be able to fetch data or session is closed exception should be thrown ?

I am not pasting big xml configuration and complete dao code which just fetch the etity with entity manager. Transaction propagation attribute is Required

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Will same session be used for fetching entities at line1 and line2 ?

yes you are right (assuming you are not using PersistenceContextType.EXTENDED)

Now if i remove @Transactional(). I believe session will be closed as soon as entity1 is fetched and separate session will be used for line2. Right ?

I don't think so, but check this and this.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda