What are First and Second Level caching in Hibernate?

Can anyone explain in simple words what First and Second Level caching in Hibernate are?


1.1) First-level cache

First-level cache always Associates with the Session object. Hibernate uses this cache by default. Here, it processes one transaction after another one, means wont process one transaction many times. Mainly it reduces the number of SQL queries it needs to generate within a given transaction. That is instead of updating after every modification done in the transaction, it updates the transaction only at the end of the transaction.

1.2) Second-level cache

Second-level cache always associates with the Session Factory object. While running the transactions, in between it loads the objects at the Session Factory level, so that those objects will be available to the entire application, not bound to single user. Since the objects are already loaded in the cache, whenever an object is returned by the query, at that time no need to go for a database transaction. In this way the second level cache works. Here we can use query level cache also. Later we will discuss about it.

Quoted from: http://www.javabeat.net/articles/37-introduction-to-hibernate-caching-1.html

Need Your Help

Using a vector of unique pointers to an <Employee> vector

c++ pointers vector ostream

For a school assignment, I am trying to use a vector of unique pointer's to Employee objects to access the Employee data, but can't figure out the syntax/compiler errors. Can anybody please tell me...

Is date/time part of SQL Server's datetimeoffset UTC or local?

sql-server sql-server-2008 timezone

According to Microsoft's page on the datetimeoffset data type (see here):

Do modern-day VisualStudio .NET projects still use Visual SourceSafe, or SVN?

.net svn visual-sourcesafe

I'm getting back into .NET after numerous years in PHP/MySQL back in 2002 on Microsoft projects we always used Visual SourceSafe and everyone hated it in all my PHP/MySQL projects we used SVN and

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.