• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate 2nd level cache - Real time aplication

 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why Hibernate 2nd level cache is not suitable for Finacial applications(Real Time) ? Any other option ?
 
thanooj kalathuru
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kri shan wrote:Why Hibernate 2nd level cache is not suitable for Finacial applications(Real Time) ? Any other option ?


A Hibernate Session is a transaction-level cache of persistent data. It is possible to configure a cluster or JVM-level (SessionFactory-level) cache on a class-by-class and collection-by-collection basis.

if and only if ....The second-level cache is typically the more important to understand, particularly when dealing with large, complex object that may be queried and loaded often.

and obviously,it leads operation process slow.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real reason is because data that changes, and even more importantly changes often, like bank account balances make incredibly bad choices for second level cache. Because the changing data invalidates the cache a lot, and in clustered environment causes a lot of changed data to be updated across all the machines (replicated). This is a huge drain on performance and resources.

Also data that might be changed by another application outside of the cache doesn't make for great second level cache because the cache will never know that the data was changed underneath them. With this type of scenario though you can set a timeout for the cache to invalidate itself and reload data.

Now, data that doesn't, if very rarely, changes makes the best second level cache data (It does not have to be a complex object).

Mark
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i use Hibernate without second level caching for long living transaction.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not in a real time application, for the same reasons Mark has already given you about the second level cache.
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hence JDBC is the only chioce for real time/Financial applications. Any other choice ? I was planning to replace JDBC to Hibernate for supporting multiple databases(Oracle/Mysql/..). If i implement Hibernate instead of JDBC, easy to migrate database from oracle to MySql without changing the appliciation code. Any comments ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kri shan wrote:Hence JDBC is the only chioce for real time/Financial applications. Any other choice ? I was planning to replace JDBC to Hibernate for supporting multiple databases(Oracle/Mysql/..). If i implement Hibernate instead of JDBC, easy to migrate database from oracle to MySql without changing the appliciation code. Any comments ?


Sorry, but that is incorrect. 2nd Level cache is an option and has nothing to do with JDBC, Hibernate or any ORM. You can have a second level cache implementation with any of those apis, and even with no database at all. And Hibernate has definitely been used in Financial Applications.

Mark

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic