Introduce second level caching
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 4 Jul 2008 19:18:28 +0000 (19:18 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 4 Jul 2008 19:18:28 +0000 (19:18 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1355 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.hibernate/pom.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/cache/ehcache.xml [new file with mode: 0644]
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/process/SlcExecution.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/process/SlcExecutionStep.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/spring/applicationContext.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/structure/SimpleSElement.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/test/SimpleResultPart.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/test/TestRunDescriptor.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/test/tree/PartSubList.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/test/tree/TreeTestResult.hbm.xml
org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/test/tree/TreeTestResultCollection.hbm.xml

index 5f0da4127ca42e195509f233f2799529137734cb..35aed6e4dd73d6c5e22171459f2c40a4b6861683 100644 (file)
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-jdbc</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-context-support</artifactId>
+               </dependency>
 
                <dependency>
                        <groupId>hsqldb</groupId>
diff --git a/org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/cache/ehcache.xml b/org.argeo.slc.hibernate/src/main/resources/org/argeo/slc/hibernate/cache/ehcache.xml
new file mode 100644 (file)
index 0000000..6082951
--- /dev/null
@@ -0,0 +1,48 @@
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="ehcache.xsd">
+
+       <diskStore path="java.io.tmpdir" />
+
+       <defaultCache maxElementsInMemory="10000" overflowToDisk="false" />
+
+       <cache name="org.argeo.slc.core.test.tree.TreeTestResult"
+               maxElementsInMemory="1000" />
+       <cache name="org.argeo.slc.core.test.tree.TreeTestResult.attributes"
+               maxElementsInMemory="1000" />
+       <cache name="org.argeo.slc.core.test.tree.PartSubList"
+               maxElementsInMemory="5000" />
+       <cache name="org.argeo.slc.core.test.tree.PartSubList.parts"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.test.SimpleResultPart"
+               maxElementsInMemory="10000" />
+       <cache
+               name="org.argeo.slc.core.test.tree.TreeTestResult.resultParts"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.test.tree.TreeTestResult.elements"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.structure.SimpleSElement"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.structure.SimpleSElement.tags"
+               maxElementsInMemory="20000" />
+
+       <cache name="org.argeo.slc.core.test.tree.TreeTestResultCollection"
+               maxElementsInMemory="100" />
+       <cache
+               name="org.argeo.slc.core.test.tree.TreeTestResultCollection.results"
+               maxElementsInMemory="1000" />
+
+       <cache name="org.argeo.slc.core.process.SlcExecution"
+               maxElementsInMemory="1000" />
+       <cache name="org.argeo.slc.core.process.SlcExecution.attributes"
+               maxElementsInMemory="5000" />
+       <cache name="org.argeo.slc.core.process.SlcExecution.steps"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.process.SlcExecutionStep"
+               maxElementsInMemory="10000" />
+       <cache name="org.argeo.slc.core.process.SlcExecutionStep.logLines"
+               maxElementsInMemory="100000" />
+
+       <cache name="org.argeo.slc.core.test.TestRunDescriptor"
+               maxElementsInMemory="1000" />
+
+</ehcache>
\ No newline at end of file
index 59781dca8f37243b283eb87a5a320856f5a4dda4..5a97024217205fdb39d09e6120b686b6f46830d7 100644 (file)
@@ -4,6 +4,8 @@
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.process">\r
        <class name="SlcExecution" table="SLC_EXECUTION">\r
+               <cache usage="read-write" />\r
+\r
                <id name="uuid" column="UUID" />\r
                <property name="host" column="HOST" />\r
                <property name="user" column="USER" />\r
@@ -11,6 +13,7 @@
                <property name="status" column="STATUS" />\r
 \r
                <list name="steps" cascade="all" table="SLC_EXECUTIONS_STEPS">\r
+                       <cache usage="read-write" />\r
                        <key column="SLC_EXECUTION_ID" />\r
                        <list-index column="INDX" />\r
                        <one-to-many
@@ -19,6 +22,8 @@
 
                <map name="attributes" table="SLC_EXEC_ATTRS_MAP" cascade="all"
                        lazy="false" sort="natural">
+                       <cache usage="read-write" />
+
                        <key column="PARENT_ID" />
                        <map-key column="ATTR_NAME" type="string" />
                        <element column="NAME" type="string" />
index ce22c71a4a6b3b8293534e29c24223b007baa5c0..c8888efa4d448e9a190b2dd8be693150c6d458ba 100644 (file)
@@ -1,18 +1,21 @@
-<?xml version="1.0"?>\r
+<?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC\r
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.process">\r
        <class name="SlcExecutionStep" table="SLC_EXECUTION_STEP">\r
+               <cache usage="nonstrict-read-write" />\r
+\r
                <id name="uuid" column="UUID" />\r
                <property name="type" column="TYPE" />\r
                <property name="begin" column="BEGIN" />\r
 \r
-               <list name="logLines" cascade="all" lazy="false"\r
-                       table="SLC_EXECUTION_STEP_LOG_LINE">\r
-                       <key column="SLC_EXECUTION_STEP_ID" />\r
-                       <list-index column="INDX" />\r
-                       <element column="LOG_LINE" type="string" />\r
-               </list>\r
-       </class>\r
+               <list name="logLines" cascade="all" lazy="false"
+                       table="SLC_EXECUTION_STEP_LOG_LINE">
+                       <cache usage="nonstrict-read-write" />
+                       <key column="SLC_EXECUTION_STEP_ID" />
+                       <list-index column="INDX" />
+                       <element column="LOG_LINE" type="string" />
+               </list>
+       </class>
 </hibernate-mapping>
\ No newline at end of file
index d7eb22266ebf4707342ed5420acb67aadb0ac423..1d59de1a6660f05c4ad66c130445b83b33a38f1f 100644 (file)
@@ -1,83 +1,97 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
-       default-lazy-init="true">\r
-\r
-       <bean id="slcDefault.dataSource.inMemoryTestHSQL"\r
-               class="org.springframework.jdbc.datasource.SingleConnectionDataSource"\r
-               destroy-method="destroy">\r
-               <property name="driverClassName" value="org.hsqldb.jdbcDriver" />\r
-               <property name="url" value="jdbc:hsqldb:mem:test" />\r
-               <property name="username" value="sa" />\r
-               <property name="password" value="" />\r
-               <property name="suppressClose" value="true" />\r
-       </bean>\r
-\r
-       <bean id="slcTemplates.sessionFactory.hibernateBasic"\r
-               abstract="true"\r
-               class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">\r
-               <property name="mappingResources">\r
-                       <list>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
+       default-lazy-init="true">
+
+       <bean id="slcDefault.dataSource.inMemoryTestHSQL"
+               class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
+               destroy-method="destroy">
+               <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+               <property name="url" value="jdbc:hsqldb:mem:test" />
+               <property name="username" value="sa" />
+               <property name="password" value="" />
+               <property name="suppressClose" value="true" />
+       </bean>
+
+       <bean id="slcTemplates.sessionFactory.hibernateBasic"
+               abstract="true"
+               class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+               <property name="mappingResources">
+                       <list>
                                <value>
                                        org/argeo/slc/hibernate/structure/SimpleSElement.hbm.xml
                                </value>
                                <value>
                                        org/argeo/slc/hibernate/test/SimpleResultPart.hbm.xml
                                </value>
-                               <value>\r
-                                       org/argeo/slc/hibernate/test/tree/TreeTestResult.hbm.xml\r
-                               </value>\r
-                               <value>\r
-                                       org/argeo/slc/hibernate/test/tree/TreeTestResultCollection.hbm.xml\r
-                               </value>\r
-                               <value>\r
-                                       org/argeo/slc/hibernate/test/tree/PartSubList.hbm.xml\r
-                               </value>\r
-                               <value>\r
-                                       org/argeo/slc/hibernate/test/TestRunDescriptor.hbm.xml\r
-                               </value>\r
-                               <value>\r
-                                       org/argeo/slc/hibernate/process/SlcExecution.hbm.xml\r
-                               </value>\r
-                               <value>\r
-                                       org/argeo/slc/hibernate/process/SlcExecutionStep.hbm.xml\r
-                               </value>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="slcDefault.sessionFactory.hibernateTestHSQL"\r
-               parent="slcTemplates.sessionFactory.hibernateBasic">\r
-               <property name="dataSource"\r
-                       ref="slcDefault.dataSource.inMemoryTestHSQL" />\r
-               <property name="hibernateProperties">\r
+                               <value>
+                                       org/argeo/slc/hibernate/test/tree/TreeTestResult.hbm.xml
+                               </value>
+                               <value>
+                                       org/argeo/slc/hibernate/test/tree/TreeTestResultCollection.hbm.xml
+                               </value>
+                               <value>
+                                       org/argeo/slc/hibernate/test/tree/PartSubList.hbm.xml
+                               </value>
+                               <value>
+                                       org/argeo/slc/hibernate/test/TestRunDescriptor.hbm.xml
+                               </value>
+                               <value>
+                                       org/argeo/slc/hibernate/process/SlcExecution.hbm.xml
+                               </value>
+                               <value>
+                                       org/argeo/slc/hibernate/process/SlcExecutionStep.hbm.xml
+                               </value>
+                       </list>
+               </property>
+               <property name="cacheProvider"
+                       ref="slcDefault.cacheProvider.ehCache" />
+       </bean>
+
+       <bean id="slcDefault.cacheProvider.ehCache"
+               class="net.sf.ehcache.hibernate.SingletonEhCacheProvider"
+               depends-on="slcDefault.cacheProvider.ehCacheManager">
+       </bean>
+
+       <bean id="slcDefault.cacheProvider.ehCacheManager"
+               class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
+               <property name="shared" value="true" />
+               <property name="configLocation"
+                       value="classpath:/org/argeo/slc/hibernate/cache/ehcache.xml" />
+       </bean>
+
+       <bean id="slcDefault.sessionFactory.hibernateTestHSQL"
+               parent="slcTemplates.sessionFactory.hibernateBasic">
+               <property name="dataSource"
+                       ref="slcDefault.dataSource.inMemoryTestHSQL" />
+               <property name="hibernateProperties">
                        <value><![CDATA[\r
                                hibernate.dialect=org.hibernate.dialect.HSQLDialect\r
                                hibernate.hbm2ddl.auto=create\r
-                               hibernate.current_session_context_class=thread\r
-                       ]]></value>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="slcTemplates.dao.testResultDao"\r
-               class="org.argeo.slc.hibernate.test.tree.TreeTestResultDaoHibernate"\r
-               abstract="true">\r
-       </bean>\r
-\r
-       <bean id="slcTemplates.dao.testResultCollectionDao"\r
-               class="org.argeo.slc.hibernate.test.tree.TreeTestResultCollectionDaoHibernate"\r
-               abstract="true">\r
-       </bean>\r
-\r
-       <bean id="slcTemplates.dao.testRunDescriptorDao"\r
-               class="org.argeo.slc.hibernate.test.TestRunDescriptorDaoHibernate"\r
-               abstract="true">\r
-       </bean>\r
-\r
-       <bean id="slcTemplates.dao.slcExecutionDao"\r
-               class="org.argeo.slc.hibernate.process.SlcExecutionDaoHibernate"\r
-               abstract="true">\r
-       </bean>\r
-\r
+                               hibernate.current_session_context_class=thread
+                       ]]></value>
+               </property>
+       </bean>
+
+       <bean id="slcTemplates.dao.testResultDao"
+               class="org.argeo.slc.hibernate.test.tree.TreeTestResultDaoHibernate"
+               abstract="true">
+       </bean>
+
+       <bean id="slcTemplates.dao.testResultCollectionDao"
+               class="org.argeo.slc.hibernate.test.tree.TreeTestResultCollectionDaoHibernate"
+               abstract="true">
+       </bean>
+
+       <bean id="slcTemplates.dao.testRunDescriptorDao"
+               class="org.argeo.slc.hibernate.test.TestRunDescriptorDaoHibernate"
+               abstract="true">
+       </bean>
+
+       <bean id="slcTemplates.dao.slcExecutionDao"
+               class="org.argeo.slc.hibernate.process.SlcExecutionDaoHibernate"
+               abstract="true">
+       </bean>
+
 </beans>
\ No newline at end of file
index 0bc9e6aea230ac83f1e2b6fcf7b8448c9505bd86..0c20f317065eeea714b216952682966d13d2e121 100644 (file)
@@ -1,18 +1,20 @@
-<?xml version="1.0"?>\r
+<?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC\r
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.structure">\r
        <class name="SimpleSElement" table="SIMPLE_SELEMENT">\r
+               <cache usage="nonstrict-read-write" />\r
                <id name="tid" column="T_ID">\r
                        <generator class="native" />\r
                </id>\r
                <property name="label" column="LABEL" not-null="true" />\r
-               <map name="tags" table="SIMPLE_SELEMENT_TAGS" cascade="all"\r
-                       lazy="false" sort="natural">\r
-                       <key column="PARENT_ID" />\r
-                       <map-key type="string" column="NAME" />\r
-                       <element type="string" column="VALUE" />\r
-               </map>\r
-       </class>\r
+               <map name="tags" table="SIMPLE_SELEMENT_TAGS" cascade="all"
+                       lazy="false" sort="natural">
+                       <cache usage="nonstrict-read-write" />
+                       <key column="PARENT_ID" />
+                       <map-key type="string" column="NAME" />
+                       <element type="string" column="VALUE" />
+               </map>
+       </class>
 </hibernate-mapping>
\ No newline at end of file
index 8a7e9da70d5f80bb4e0836d70a2deb77b5c48c31..acd3b8cc5bbe0b5afc6dec2162fb030171b9593f 100644 (file)
@@ -4,6 +4,7 @@
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.test">\r
        <class name="SimpleResultPart" table="SIMPLE_RESULT_PART">\r
+               <cache usage="nonstrict-read-write" />
                <id name="tid" column="T_ID">\r
                        <generator class="native" />\r
                </id>\r
index a00332cc2ccd21e19c58791cec87aded7ac9aa58..f28c1264e09d8a3046f49b3475e0887183318236 100644 (file)
@@ -4,6 +4,7 @@
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.test">\r
        <class name="TestRunDescriptor" table="TEST_RUN_DESCRIPTOR">\r
+               <cache usage="nonstrict-read-write" />
                <id name="testRunUuid" column="TEST_RUN_UUID" />\r
                <property name="slcExecutionUuid" column="SLC_EXEC_UUID"\r
                        not-null="false" />\r
index 3a593acdf11ab2ccbafc40ecd364ca241f947abe..23d41760881a80105f0026c6104d9c6211279718 100644 (file)
@@ -4,10 +4,12 @@
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.test.tree">\r
        <class name="PartSubList" table="PART_SUB_LIST">\r
+               <cache usage="nonstrict-read-write" />\r
                <id name="tid" column="T_ID">\r
                        <generator class="native" />\r
                </id>\r
                <list name="parts" cascade="all" table="PARTS_LIST">\r
+                       <cache usage="nonstrict-read-write" />\r
                        <key column="PART_SUBLIST_ID" />\r
                        <list-index column="INDX" />\r
                        <many-to-many
index eb4a38a77eaa62ce994e2121f69aa768e9e07663..5397a64bd6ae239bc1a9707474805b503834ac30 100644 (file)
@@ -4,6 +4,7 @@
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
 <hibernate-mapping package="org.argeo.slc.core.test.tree">\r
        <class name="TreeTestResult" table="TREE_TEST_RESULT">\r
+               <cache usage="read-write" />\r
                <id name="uuid" column="UUID" />\r
 \r
                <property name="closeDate" column="CLOSE_DATE" type="timestamp"
@@ -11,6 +12,7 @@
 
                <map name="attributes" table="TTR_ATTRS_MAP" cascade="all"
                        lazy="false" sort="natural">
+                       <cache usage="read-write" />
                        <key column="PARENT_ID" />
                        <map-key column="ATTR_NAME" type="string" />
                        <element column="NAME" type="string" />
@@ -18,6 +20,7 @@
 
                <map name="resultParts" table="RESULT_PARTS_MAP" cascade="all"
                        sort="natural">
+                       <cache usage="nonstrict-read-write" />
                        <key column="PARENT_ID" />
                        <composite-map-key
                                class="org.argeo.slc.core.structure.tree.TreeSPath">
@@ -29,6 +32,7 @@
 
                <map name="elements" table="RESULT_ELEMENTS_MAP" cascade="all"
                        sort="natural">
+                       <cache usage="nonstrict-read-write" />
                        <key column="PARENT_ID" />
                        <composite-map-key
                                class="org.argeo.slc.core.structure.tree.TreeSPath">
index 82d976052fe8e178277f2c5eef2d089ac79d7d1f..f7fac780b7a6ae1595c76f8e9c559122208c73c8 100644 (file)
@@ -5,10 +5,12 @@
 <hibernate-mapping package="org.argeo.slc.core.test.tree">\r
        <class name="TreeTestResultCollection"
                table="TREE_TEST_RESULT_COLLECTION">
+               <cache usage="nonstrict-read-write" />
                <id name="id" column="ID" />
 
                <set name="results" table="TTR_COLLECTION_RESULTS"
                        sort="natural">
+                       <cache usage="read-write" />
                        <key column="PARENT_ID" />
                        <many-to-many class="TreeTestResult" />
                </set>