[jboss-user] [JBossCache] - Using JBossCache on a Java Persistence with Hibernate standa

newbeee do-not-reply at jboss.com
Mon Dec 17 23:44:15 EST 2007


Hi There,

   I am using JBossCache on a Java Persistence with Hibernate standalone program. 

    My persistence.xml file has 

<persistence-unit name="ehiveimport" transaction-type="RESOURCE_LOCAL">
  | 
  | 		<properties>
  |       		<property name="hibernate.connection.url" value="jdbc:derby:importDB"/>
  | 			<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
  | 			<property name="hibernate.connection.password" value="importDB"/>
  | 			<property name="hibernate.connection.username" value="importDB"/>
  | 			<!-- <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>-->
  | 			<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
  | 			
  | 			<property name="hibernate.cache.use_second_level_cache" value="false"/>
  | 			 <!-- Provider is JBoss Cache with Optimistic locking -->
  | 	        <property name="hibernate.cache.provider_class"  value="org.hibernate.cache.OptimisticTreeCacheProvider"/>
  | 	        <!-- JBoss Cache configuration file name -->
  | 	        <property name="hibernate.cache.provider_configuration_file_resource_path" value="jboss-cache.xml"/>
  | 	        <!-- Use query cache too  -->
  | 	        <property name="hibernate.cache.use_query_cache" value="true"/>
  | 
  |  <property name="hibernate.transaction.manager_lookup_class"  value="com.ehive.transaction.EHiveJBossTransactionManagerLookup"/>
  | 
  | </properties>
  | 		
  | </persistence-unit>

And my jboss-cache.xml has 

<?xml version="1.0" encoding="UTF-8" ?>
  | <server>
  |   <classpath codebase="./lib/jboss" archives="jboss-cache-jdk50.jar, jgroups.jar" />
  | 
  |   <!--  ====================================================================  -->
  |   <!--  Defines TreeCache configuration                                       -->
  |   <!--  ====================================================================  -->
  |   <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
  |     <depends>jboss:service=Naming</depends>
  |     <depends>jboss:service=TransactionManager</depends>
  | 
  | 
  |     <!-- Configure the TransactionManager -->
  |     <attribute name="TransactionManagerLookupClass">
  |        org.jboss.cache.GenericTransactionManagerLookup
  |     </attribute>
  | 
  | <!-- 
  | Node locking scheme : PESSIMISTIC (default) OPTIMISTIC -->
  | <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
  | 
  |     <!--
  |             Node locking isolation level : 
  |  								 SERIALIZABLE
  |                                  REPEATABLE_READ (default)
  |                                  READ_COMMITTED
  |                                  READ_UNCOMMITTED
  |                                  NONE
  | 
  | (ignored if NodeLockingScheme is OPTIMISTIC)
  |     -->
  |     <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
  | 
  |     <!-- Lock parent before doing node additions/removes -->
  |     <attribute name="LockParentForChildInsertRemove">true</attribute>
  | 
  |     <!--     Valid modes are LOCAL
  |                              REPL_ASYNC
  |                              REPL_SYNC
  |                              INVALIDATION_ASYNC
  |                              INVALIDATION_SYNC
  |     -->
  |     <attribute name="CacheMode">REPL_SYNC</attribute>
  |     
  |     <!--  Whether each interceptor should have an mbean
  |         registered to capture and display its statistics.  -->
  |     <attribute name="UseInterceptorMbeans">true</attribute>
  | 
  |     <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
  |     cluster, in order to find each other -->
  |     <attribute name="ClusterName">JBoss-Cache-Cluster</attribute>
  | 
  | 
  |     <!--    The max amount of time (in milliseconds) we wait until the
  |             initial state (ie. the contents of the cache) are retrieved from
  |             existing members in a clustered environment
  |     -->
  |     <attribute name="InitialStateRetrievalTimeout">5000</attribute>
  | 
  |     <!--    Number of milliseconds to wait until all responses for a
  |             synchronous call have been received.
  |     -->
  |     <attribute name="SyncReplTimeout">10000</attribute>
  | 
  |     <!--  Max number of milliseconds to wait for a lock acquisition -->
  |     <attribute name="LockAcquisitionTimeout">15000</attribute>
  | 
  |    
  | 
  |   </mbean>
  | </server>     

In my entity beans I have 
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)

Caching does not  improve performance when I do a query entityManager.find(......)

With or without caching it takes same time. 

Could you please let me know what am I missing and what needs to be done. 

Thanks


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113631#4113631

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113631



More information about the jboss-user mailing list