Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!