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

  • SEARCH
  • Home
  • 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 6883319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:22:04+00:00 2026-05-27T05:22:04+00:00

My service bean example @Service(officeService) @Transactional public class OfficeService { @Resource(name = sessionFactory) private

  • 0

My service bean example

@Service("officeService")
@Transactional
public class OfficeService {

    @Resource(name = "sessionFactory")
    private SessionFactory sessionFactory;

    @Transactional(readOnly=true)
    public List<Office> getAllOffices(){
      Session session = sessionFactory.getCurrentSession();
      Criteria crit = session.createCriteria(Office.class);
      crit.addOrder(Order.desc("name"));
      return crit.list();
    }
}

What would it look like if it were not thread safe (or isn’t it already) ?

And if my all my controllers and services are singletons, does this mean that each request simply acts on the singletons concurrently when required ?

  • 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-27T05:22:05+00:00Added an answer on May 27, 2026 at 5:22 am

    If you managed any state within the class as instance variables then it wouldn’t be thread safe. Since the only state you have is the sessionFactory, as long as its getCurrentSession() method is thread safe (which it is), then so is your method

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

Sidebar

Related Questions

@Service @Repository @Transactional public class VideoService { @PersistenceContext EntityManager entityManager; public void save(Video video)
I'm trying to create a service bean that when referenced will be initialized with
I'm getting LazyInitializationException with session scoped bean in my service layer. If I load
I'm attempting to implement a delegate Service provider by overriding the bean definition for
I have the following bean defined: <sec:authentication-manager alias=authenticationManager> <sec:authentication-provider user-service-ref=userDetailsService /> </sec:authentication-manager> I guess
My Service Contract [ServiceContract] public interface ITsdxService { [OperationContract] [WebGet(UriTemplate=/GetTestCostCentre)] CostCentre GetTestCostCentre(); [OperationContract] [WebInvoke(UriTemplate=/SetCostCentre,
For example, I have created a slew of 'test-my-service' Objects in my Spring config
I have a service bean (annotated with @Service) which implements the ApplicationListener inteface for
I have a page with a datatable that reads data from a service class.
Given an example of calling two web services methods from a session bean, what

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.