answersLogoWhite

0


Best Answer

SessionFactory is Hibernates concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application code.

SessionFactory sessionFactory = new Configuration().configure().buildSessionfactory();

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why Session Factory is thread safe in hibernate?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is thread safe object?

A thread safe object is one that would be safe even if multiple thread instances are accessing it. For example if a single object is being updated by a thread and the same object is being read by another thread - we will end up with an inconsistency where the reading object is reading incorrect data because by the time it finishes reading, another thread would've updated it. So we use the keyword synchronized with methods to ensure that such a situation does not happen. An object that wont let two threads access it simultaneously is called a thread safe object


What makes a java method code thread-safe?

The cleanest way to make a method thread-safe is add to the method declaration the synchronized keyword, like this: public class MyClass{ // More code here public synchronized void safeMethod(){ //Do something here, now is safe } } The above code is the same as: public class MyClass{ // More code here public void safeMethod(){synchronized (this){ //Do something here, now is safe } } }


When should the method invokeLater be used?

invokeLater should be used when your code is performing a GUI change in the Swing UI library, and you cannot guarantee that the change is being made in the Event Dispatching Thread (which can cause data problems, as Swing is not "thread-safe"). So, invokeLater should be used if (1) you are using Swing, and (2) you are using Thread, and (3) the thread from 2 needs to update a GUI element that is part of Swing.


What is vector how is different in array?

A Vector is a collection while an Array is a simple data typeVectors are thread safe by default, arrays are notVectors can grow in size automatically whereas you have to declare the initial size of an array and it does not grow in size


I shut off my computer during a scandisk session now it won't let me delete files saying the file directory is corrupt and unreadable?

Try running scandisk through again. If that doesn't work, try deleting the file in safe mode (press f8 just before seeing the windows logo when you turn on your computer)

Related questions

Is Servlet instance Thread safe If not how can you make thread safe?

No. The Servlet is not thread-safe by default. You can make it thread safe by implementing the SingleThreadedModel interface


Is jsp thread safe by default?

No. JSPs are not thread safe by default


What is the factory combination for your safe?

what is the factory combination for my safe ?


How do squirrls hibernate?

Squirrels hibernate by first hiding there food in safe environment and then by going into a tree to sleep for the depending time on which they wish to hibernate.


How lizard stay safe?

they hibernate and blend into their habitat


Is thread safe for parrots?

If it is large enough.


What is thread safe object?

A thread safe object is one that would be safe even if multiple thread instances are accessing it. For example if a single object is being updated by a thread and the same object is being read by another thread - we will end up with an inconsistency where the reading object is reading incorrect data because by the time it finishes reading, another thread would've updated it. So we use the keyword synchronized with methods to ensure that such a situation does not happen. An object that wont let two threads access it simultaneously is called a thread safe object


What are three stages of a safe exercice session?

Define the three stages of a safe activity.


Characteristic of factory labor?

Factory working conditions were not safe.


What do you do if you forget the combinations to your safe?

Call the factory that made the safe?


What is a negative characteristic of factory labor?

factory working conditions were not safe


What are the characteristics of labor?

Factory working conditions were not safe.