Hibernate is a free and popular object-relational mapping engine for Java that simplifies development by letting you map domain objects to your database tables. And, high traffic Java applications using Hibernate face scalability issues related to database just like all other high traffic applications.
To address this scalability issue, Hibernate provides Second Level Cache architecture which lets you plug in an in-memory data grid. TayzGrid is an extremely fast and linearly scalable in-memory data grid that lets you handle extreme transaction loads. TayzGrid has implemented a Hibernate Second Level Cache provider to allow Hibernate applications to benefit from its capabilities.
You can plug-in TayzGrid as Hibernate Second Level Cache without any programming or even recompilation of your code. You only need to modify app.config file as follows.
<hibernate-configuration> <session-factory> ... <property name="hibernate.cache.use_second_level_cache"> true </property> <property name="hibernate.cache.region.factory_class"> com.alachisoft.tayzgrid.integrations.hibernate.cache.TayzGridRegionFactory </property> <property name="tayzgrid.application_id"> myapp </property> <property name="hibernate.cache.use_query_cache"> true </property> ... </session-factory> </hibernate-configuration> <!--2nd section --> <hibernate-mapping> <class name="hibernator.BLL.Customer" table="customers"> <cache usage="read-write" region="AbsoluteExpirationRegion"/> ... </class> </hibernate-mapping>
And, here in Customer.hbm.xml, you specify if Hibernate should store this class in TayzGrid. You do this for each class that Hibernate is using.
<hibernate-mapping> <class name="hibernator.BLL.Customer" table="customers"> <cache usage="read-write" region="AbsoluteExpirationRegion"/> ... </class> </hibernate-mapping>
And, below in TayzGridHibernate.xml you can specify TayzGrid configuration for Hibernate.
<configuration> <application-config application-id="myapp" enable-cache-exception="true" default-region-name="DefaultRegion" key-case-sensitivity="false"> <cache-regions> ... <region name="DefaultRegion" cache-name="mycache" priority="default" expiration-type="none" expiration-period="0"/> </cache-regions> <database-dependencies> <dependency entity-name="hibernator.BLL.Customer" type="oledb" sql-statement="select ContactName from dbo.Customers where CustomerID =?" cache-key-format="depdency.customer:[pk]"/> </database-dependencies> </application-config> </configuration>
Despite the fact that Hibernate Second Level Cache provider makes it really easy for you to incorporate TayzGrid into your Java application, you should keep in mind that you only get a subset of TayzGrid features through this integration. If you make direct API calls into TayzGrid through a small programming effort, you would gain the following features.