These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problème/utilisation du cache nv2 ehcache - Websphere 6
PostPosted: Thu Apr 05, 2007 5:52 am 
Newbie

Joined: Wed Apr 04, 2007 12:19 pm
Posts: 1
Bonjour,

J'ai un soucis avec la mise en cache d'un mapping sous websphere 6,
je souhaite mapper un code statut en un autre via une table de mapping avec une mise en cache.

Sous eclipse lors de mes tests de mise en cache avec le même code ou presque (c'est a dire sans Session Bean) cela semble fonctionner:
i.e lorsque je fais un changement en base des valeurs, les modification ne prennent pas effet directement dans l'application car le cache est renouvelé qu'a partir de nn secondes, les nn secondes passé le cache est a jour.

Lorsque j'applique la même "recette" dans mon SessionBean InterfaceManagerbean le cache ne semble pas fonctionner, les modifications en base de mes valeurs celle-ci sont instantanément prises en compte.


Quelqu'un aurait une idée sur l'origine du problème ?


Extrait de mon fichier « InterfaceManagerBean.java » :

Code:
public void treatDemand(){

[…..]

StatusMappingManager mappingStatus = new StatusMappingManager();
       
      for (int i = 1; i <= 100; i++) { Transaction tx = SessionManager.getSession().beginTransaction();
      Status statusMappe = mappingStatus.findMappingBySourceStatus(statusNonMappe);
      tx.commit();
      System.err.println("STATUT: " + statusMappe.getStatus()+"");
      SessionManager.closeSession();
      }

[….]
}



Extrait de mon fichier « class StatusMappingManager.java » :

Code:
public class StatusMappingManager {
    public Status findMappingBySourceStatus(String sourceStatus) {
        return (Status) SessionManager.currentSession().createQuery("from Status where sourceStatus = :sourceStatus").setParameter("sourceStatus", sourceStatus).uniqueResult();
    }

    public List getMappingStatus() {
        return SessionManager.currentSession().createQuery("from Status order by sourceStatus").setCacheable(true).list();
    }
}



Extrait de mon fichier « class Status.java » :

Quote:
public class Status implements Serializable {
private static final long serialVersionUID = 1L;
private int status;
private String sourceStatus;
private String statusFlag;

public Status() {
}

/**
* @param status
* @param sourceStatus
* @param statusFlag
*/
public Status(int status, String sourceStatus, String statusFlag) {
super();
this.status = status;
this.sourceStatus = sourceStatus;
this.statusFlag = statusFlag;
}

/**
* @return Returns the sourceStatus.
*/
[….]



Mon fichier de mapping “x_config_mapping_t.hbm.xml”;

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.intf.cmp">
<class name="Status" table="X_CONFIG_STATUS_MAPPING_T">
  <cache usage="read-only" region="maregion"/>
  <id name="sourceStatus" type="string">
            <column name="SOURCE_STATUS" length="2" />
            <generator class="assigned" />
  </id>
  <property name="status" type="int" column="STATUS"/>
  <property name="statusFlag" type="string" column="STATUS_FLAG"/>
</class>
</hibernate-mapping>



Mon fichier de config “hibernate.cfg.xml”;


Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
       
        <property name="hibernate.connection.url">jdbc:oracle:thin:@XXX:1529:XXXX</property>
        <property name="hibernate.connection.username">XXX</property>
        <property name="hibernate.connection.password">XXX</property>
       
        <!-- JDBC connection pool (use the built-in) -->
        <property name="hibernate.connection.pool_size">1</property>
        <!-- SQL dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
        <!-- Enable Hibernate's automatic session context management -->
        <property name="hibernate.current_session_context_class">thread</property>
   
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
       <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>
   <property name="hibernate.current_session_context_class">jta</property>
   <property name="hibernate.transaction.flush_before_completion">true</property>

        <!-- Enable second-level EHCache-->
        <property name="hibernate.cache.use_second_level_cache">true</property>
        <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
        <property name="hibernate.cache.use_query_cache">true</property>
        <mapping resource="com/intf/cmp/x_config_status_mapping_t.hbm.xml"/>
    </session-factory>
</hibernate-configuration>



Mon fichier de config “ehcache.xml”;

Code:
<ehcache>
   <diskStore path="java.io.tmpdir" />
   <defaultCache
      maxElementsInMemory="10000"
      eternal="false"
      timeToIdleSeconds="6"
      timeToLiveSeconds="150000"
      overflowToDisk="true"
      diskPersistent="false"
      diskExpiryThreadIntervalSeconds="300000"
   />
   <cache name="com.intf.cmp.Status"
      maxElementsInMemory="5000"
      eternal="false"
      overflowToDisk="false"
      timeToIdleSeconds="10"
      timeToLiveSeconds="20"
   />
</ehcache>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.