Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda