[jboss-user] [JBossCache] - JBossCache with Hibernate

ravi.nagubandi do-not-reply at jboss.com
Thu Nov 2 08:00:32 EST 2006


Hi,

  I am trying to integrate JBossCache with Hibernate. I am using Hibernate3.0 . I had placed the treecache.xml in my classpath and also provided entries in Hibernate configuration file related to JBossCache.

 My requirement is like when i call my DAO method first time it should hit the database and for the subsequent calls it has to fetch from the cache.

    Currently whenever i invoke my DAO method, hit on database is occuring. How can i avoid the database hits for subsequent calls.

  I am providing the code of my Configuration file and treecache.xml. 

  Please provide me help in resolving this issue.

 Thanks in advance.




  |  Hibernate Configuration file:
  | 
  | <?xml version='1.0' encoding='utf-8'?>
  | <!DOCTYPE hibernate-configuration PUBLIC
  |     "-//Hibernate/Hibernate Configuration DTD//EN"
  |     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  | 
  | <hibernate-configuration>
  | <session-factory>
  |  <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>  
  | 	<property name="hibernate.connection.url">jdbc:oracle:thin:@10.150.126.82:1521:endvu</property> 
  |     <property name="hibernate.connection.username">app_developer</property> 
  |     <property name="hibernate.connection.password">app_developer</property> 
  | <!--    <property name="hibernate.connection.datasource">jdbc/acsdatabase</property>  -->
  | 	   
  | 		<property name="show_sql">true</property>
  | 		<property name="hibernate.jdbc.use_streams_for_binary">true</property>
  | 	    <property name="dialect">org.hibernate.dialect.OracleDialect</property>
  | 		<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
  | 		<property name="hibernate.use_outer_join">true</property>
  | 		<property name="hibernate.bytecode.use_reflection_optimizer">true</property>
  | 		<property name="hibernate.generate_statistics">true</property>
  | 		<property name="hibernate.cache.use_second_level_cache">true</property>
  | 		<property name="hibernate.cache.provider_class">org.hibernate.cache.TreeCacheProvider</property>
  | 		<property name="hibernate.treecache.mbean.object_name">jboss.cache:service=TreeCache</property>
  | 		<property name="hibernate.current_session_context_class">thread</property>
  | 		<property name="TransactionManagerLookupClass">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
  | 
  |   </session-factory>
  | </hibernate-configuration>
  | 
  | 
  |  
  | 
  | [/url]


  | 
  | Treecache.xml
  | 
  | <?xml version="1.0" encoding="UTF-8"?>
  | <server>
  | 	<classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
  | 	<mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
  | 		<depends>jboss:service=Naming</depends>
  | 		<depends>jboss:service=TransactionManager</depends>
  | 		<attribute name="TransactionManagerLookupClass">
  | 			JBossCache.src.com.example.SapWasTransactionManagerLookup
  | 		</attribute>
  | 		<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
  | 		<attribute name="CacheMode">REPL_SYNC</attribute>
  | 		<attribute name="UseReplQueue">false</attribute>
  | 		<attribute name="ReplQueueInterval">0</attribute>
  | 		<attribute name="ReplQueueMaxElements">0</attribute>
  | 		<attribute name="ClusterName">SAP Web AS - Cluster</attribute>
  | 		<attribute name="ClusterConfig">
  | 			<config>
  | 				<UDP mcast_addr="230.8.8.8" mcast_port="56677" ip_ttl="32" ip_mcast="true" mcast_send_buf_size="80000" mcast_recv_buf_size="150000" ucast_send_buf_size="80000" ucast_recv_buf_size="150000" loopback="true"/>
  | 				<PING timeout="2000" num_initial_members="3" up_thread="false" down_thread="false"/>
  | 				<MERGE2 min_interval="10000" max_interval="20000"/>
  | 				<FD shun="true" up_thread="true" down_thread="true"/>
  | 				<VERIFY_SUSPECT timeout="1500" up_thread="false" down_thread="false"/>
  | 				<pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192" up_thread="false" down_thread="false"/>
  | 				<UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" down_thread="false"/>
  | 				<pbcast.STABLE desired_avg_gossip="20000" up_thread="false" down_thread="false"/>
  | 				<FRAG frag_size="8192" down_thread="false" up_thread="false"/>
  | 				<pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/>
  | 				<pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
  | 			</config>
  | 		</attribute>
  | 		<attribute name="InitialStateRetrievalTimeout">10000</attribute>
  | 		<attribute name="SyncReplTimeout">10000</attribute>
  | 		<attribute name="LockAcquisitionTimeout">15000</attribute>
  | 		<attribute name="EvictionPolicyClass"/>
  | 		<attribute name="FetchStateOnStartup">true</attribute>
  | 	</mbean>
  | 
  | </server>
  | 

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

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



More information about the jboss-user mailing list