OverviewGigaSpaces comes with a built in implementation of External Data Source, called the HibernateExternalDataSource. The HibernateExternalDataSource is a Hibernate implementation of the External Data Source interfaces. It allows a custom objects persistency using Hibernate mappings. The HibernateExternalDataSource has 2 implemenations:
The HibernateExternalDataSource used both with the Synchronous and the ASynchronous persistency modes. ConfigurationSee below example for HibernateExternalDataSource that is configured having a Space connected to a central data source using Hibernate configuration files decorating the Space Classes:
Namespace
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/> <property name="username" value="sa"/> <property name="password" value=""/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <value>Person.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">false</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.jdbc.batch_size">50</prop> </props> </property> </bean> <bean id="hibernateDataSource" class="org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource"> <property name="sessionFactory" ref="sessionFactory"/> <property name="initialLoadChunkSize" value="2000"/> </bean> <os-core:space id="space" url="/./space" schema="persistent" external-data-source="hibernateDataSource"> <os-core:properties> <props> <prop key="cluster-config.cache-loader.external-data-source">true</prop> <prop key="cluster-config.cache-loader.central-data-source">true</prop> </props> </os-core:properties> </os-core:space> Plain XML <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/> <property name="username" value="sa"/> <property name="password" value=""/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <value>Person.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">false</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.jdbc.batch_size">50</prop> </props> </property> </bean> <bean id="hibernateDataSource" class="org.openspaces.persistency.hibernate.HibernateExternalDataSource"> <property name="sessionFactory" ref="sessionFactory"/> <property name="initialLoadChunkSize" value="2000"/> </bean> <bean id="space" class="org.openspaces.core.space.UrlSpaceFactoryBean"> <property name="url" value="/./space" /> <property name="scheam" value="persistent" /> <property name="externalDataSource" ref="hibernateDataSource" /> <property name="properties"> <props> <prop key="cluster-config.cache-loader.external-data-source">true</prop> <prop key="cluster-config.cache-loader.central-data-source">true</prop> </props> </property> </bean> When using annotations to decorate the Space Classes the sessionFactory would have the following: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="annotatedClasses"> <list> <value>com.mycompany.app.common.Data</value> </list> </property> <property name="hibernateProperties"> <props> .... </props> </property> </bean>
PropertiesThe Hibernate External Data Source includes the following properties:
See example below: <bean id="hibernateDataSource" class="org.openspaces.persistency.hibernate.HibernateExternalDataSource"> <property name="sessionFactory" ref="sessionFactory"/> <property name="fetchSize" value="100"/> <property name="initialLoadChunkSize" value="2000"/> <property name="initialLoadEntries" value="myClass1,myClass2"/> <property name="managedEntries" value="myClass1,myClass2"/> <property name="initialLoadThreadPoolSize" value="10"/> <property name="performOrderById" value="true"/> <property name="useScrollableResultSet" value="true"/> <property name="useMerge" value="true"/> </bean> |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |