Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:15:39+00:00 2026-05-23T16:15:39+00:00

Can I use geCurrentSession() instead of using HibernateCallback to get the session?. If both

  • 0

Can I use geCurrentSession() instead of using HibernateCallback to get the session?. If both sessions are managed by Spring, why do I need a Callback ? Is there any performance advantage associated with this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:15:40+00:00Added an answer on May 23, 2026 at 4:15 pm

    In a well-configured Spring application, both are equivalent except in one case: when there is no current transaction context. In this case, getCurrentSession() won’t work, whereas using a HibernateCallback will open a session and a Hibernate transaction for you and close them at the end.

    Note that the documentation of HibernateTemplate mentions that getCurrentSession() should be preferred:

    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().

    It also says:

    Note that HibernateTemplate will perform its own Session management,
    not participating in a custom Hibernate CurrentSessionContext unless
    you explicitly switch “allowCreate” to “false”.

    Mixing both ways of doing is thus not a good idea.

    My preference is to avoid HibernateTemplate, use the Hibernate Session API directly, and use Spring-managed declarative transactions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can i use hibernate to login jsp page using (session) if i'm not using
You can use SelectFolder() to get a folder or GetOpenFolderitem(filter as string) to get
You can use command lsof to get file descriptors for all running processes, but
I can use Server[request_time] to get current timestamp. But how would I use this
I can use android:gravity=bottom|center_horizontal in xml on a textview to get my desired results,
I can use @font-face but it does not work in all browsers. Are there
I can use File('foo.bar').abspath to get the location of a file, but if I've
How can use the WebBrowser control in WPF to navigate using Search engine uri
You can use more than one css class in an HTML tag in current
You can use a standard dot notation or a method call in Objective-C to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.