3 Replies Latest reply on Mar 18, 2008 3:06 PM by Elias Ross

    I don't Think I am doing this Correct

    Michael Thoresen Newbie

      I am playing around with JBOSS Cache and do not know if I am doing this correct. When I do a FindAll....I can see that the cache is populated when i do a printDetail in the JMXConsole. However, when I do bench testing and keep calling the same method, FindAll..., I do not seen any performance increase. Is it still making a call to the database? It takes the same amount of time as non-cached implementation. Below is the entity i am using. It's a view in one of our tables that contains abour 20,000+ rows that I would like to have cached.


      Taken from Hibernate tutorial - : This call actually will fill the cache when it is first run. but as I do consecutive calls to this, i do not see a performance increase. They all take the same amount of time as the initial call. Is this the wrong thing to do?

      private EntityManager em;
      @PersistenceContext
      public void setEntityManager(EntityManager em) {
      this.em = em;
      }
      .
      .
      .
      .
      public List findAll() {
      return getEntityManager().createQuery("from " + getEntityBeanType().getName() ).getResultList();
      }


      @Entity(name = "VAwaitedDocs")
      @Table(schema = "OPS_TRACKING", name = "V_AWAITED_DOCS")
      @Cache(usage= CacheConcurrencyStrategy.READ_ONLY)
      public class VAwaitedDocs implements Serializable, Comparable {
      private String tradeInfo;
      private String priceInfo;
      private String trdSysCode;
      private Long tradeId;
      private Long tradeRqmtId;
      private String sender;
      private String docType;
      private Timestamp rqmtEventDt;
      private String cdtyCode;
      private String cdtyGrpCode;
      private Timestamp tradeDt;
      private String cptySn;
      private String brokerSn;
      private String bookingCompany;
      private String tradeTypeCode;
      private String sttlType;
      private String buySellInd;
      private Long qtyTot;
      private Long qty;
      private String uomDurCode;
      private String locationSn;
      private String payPrice;
      private String recPrice;
      private Timestamp startDt;
      private Timestamp endDt;
      private String bkrComm;
      private String reference;
      private String cmt;
      private String status;
      private String rqmt;
      private String finalApprovalFlag;
      private String cptyLn;

      @Basic
      @Column(name = "TRADE_INFO", length = 206)
      public String getTradeInfo() {
      return tradeInfo;
      }

      public void setTradeInfo(String tradeInfo) {
      this.tradeInfo = tradeInfo;
      }

      @Basic
      @Column(name = "PRICE_INFO", length = 130)
      public String getPriceInfo() {
      return priceInfo;
      }

      public void setPriceInfo(String priceInfo) {
      this.priceInfo = priceInfo;
      }

      @Basic
      @Column(name = "TRD_SYS_CODE", nullable = false, length = 5)
      public String getTrdSysCode() {
      return trdSysCode;
      }

      public void setTrdSysCode(String trdSysCode) {
      this.trdSysCode = trdSysCode;
      }

      @Id
      @Column(name = "TRADE_ID", nullable = false, length = 12)
      public Long getTradeId() {
      return tradeId;
      }

      public void setTradeId(Long tradeId) {
      this.tradeId = tradeId;
      }

      @Basic
      @Column(name = "TRADE_RQMT_ID", nullable = false, length = 12)
      public Long getTradeRqmtId() {
      return tradeRqmtId;
      }

      public void setTradeRqmtId(Long tradeRqmtId) {
      this.tradeRqmtId = tradeRqmtId;
      }

      @Basic
      @Column(name = "SENDER", length = 20)
      public String getSender() {
      return sender;
      }

      public void setSender(String sender) {
      this.sender = sender;
      }

      @Basic
      @Column(name = "DOC_TYPE", length = 6)
      public String getDocType() {
      return docType;
      }

      public void setDocType(String docType) {
      this.docType = docType;
      }

      @Basic
      @Column(name = "RQMT_EVENT_DT", length = 7)
      public Timestamp getRqmtEventDt() {
      return rqmtEventDt;
      }

      public void setRqmtEventDt(Timestamp rqmtEventDt) {
      this.rqmtEventDt = rqmtEventDt;
      }

      @Basic
      @Column(name = "CDTY_CODE", length = 10)
      public String getCdtyCode() {
      return cdtyCode;
      }

      public void setCdtyCode(String cdtyCode) {
      this.cdtyCode = cdtyCode;
      }

      @Basic
      @Column(name = "CDTY_GRP_CODE", length = 5)
      public String getCdtyGrpCode() {
      return cdtyGrpCode;
      }

      public void setCdtyGrpCode(String cdtyGrpCode) {
      this.cdtyGrpCode = cdtyGrpCode;
      }

      @Basic
      @Column(name = "TRADE_DT", length = 7)
      public Timestamp getTradeDt() {
      return tradeDt;
      }

      public void setTradeDt(Timestamp tradeDt) {
      this.tradeDt = tradeDt;
      }

      @Basic
      @Column(name = "CPTY_SN", length = 20)
      public String getCptySn() {
      return cptySn;
      }

      public void setCptySn(String cptySn) {
      this.cptySn = cptySn;
      }

      @Basic
      @Column(name = "BROKER_SN", length = 20)
      public String getBrokerSn() {
      return brokerSn;
      }

      public void setBrokerSn(String brokerSn) {
      this.brokerSn = brokerSn;
      }

      @Basic
      @Column(name = "BOOKING_COMPANY", length = 10)
      public String getBookingCompany() {
      return bookingCompany;
      }

      public void setBookingCompany(String bookingCompany) {
      this.bookingCompany = bookingCompany;
      }

      @Basic
      @Column(name = "TRADE_TYPE_CODE", length = 10)
      public String getTradeTypeCode() {
      return tradeTypeCode;
      }

      public void setTradeTypeCode(String tradeTypeCode) {
      this.tradeTypeCode = tradeTypeCode;
      }

      @Basic
      @Column(name = "STTL_TYPE", length = 10)
      public String getSttlType() {
      return sttlType;
      }

      public void setSttlType(String sttlType) {
      this.sttlType = sttlType;
      }

      @Basic
      @Column(name = "BUY_SELL_IND", length = 1)
      public String getBuySellInd() {
      return buySellInd;
      }

      public void setBuySellInd(String buySellInd) {
      this.buySellInd = buySellInd;
      }

      @Basic
      @Column(name = "QTY_TOT", length = 24, precision = 12)
      public Long getQtyTot() {
      return qtyTot;
      }

      public void setQtyTot(Long qtyTot) {
      this.qtyTot = qtyTot;
      }

      @Basic
      @Column(name = "QTY", length = 24, precision = 12)
      public Long getQty() {
      return qty;
      }

      public void setQty(Long qty) {
      this.qty = qty;
      }

      @Basic
      @Column(name = "UOM_DUR_CODE", length = 20)
      public String getUomDurCode() {
      return uomDurCode;
      }

      public void setUomDurCode(String uomDurCode) {
      this.uomDurCode = uomDurCode;
      }

      @Basic
      @Column(name = "LOCATION_SN", length = 20)
      public String getLocationSn() {
      return locationSn;
      }

      public void setLocationSn(String locationSn) {
      this.locationSn = locationSn;
      }

      @Basic
      @Column(name = "PAY_PRICE", length = 60)
      public String getPayPrice() {
      return payPrice;
      }

      public void setPayPrice(String payPrice) {
      this.payPrice = payPrice;
      }

      @Basic
      @Column(name = "REC_PRICE", length = 60)
      public String getRecPrice() {
      return recPrice;
      }

      public void setRecPrice(String recPrice) {
      this.recPrice = recPrice;
      }

      @Basic
      @Column(name = "START_DT", length = 7)
      public Timestamp getStartDt() {
      return startDt;
      }

      public void setStartDt(Timestamp startDt) {
      this.startDt = startDt;
      }

      @Basic
      @Column(name = "END_DT", length = 7)
      public Timestamp getEndDt() {
      return endDt;
      }

      public void setEndDt(Timestamp endDt) {
      this.endDt = endDt;
      }

      @Basic
      @Column(name = "BKR_COMM", length = 60)
      public String getBkrComm() {
      return bkrComm;
      }

      public void setBkrComm(String bkrComm) {
      this.bkrComm = bkrComm;
      }

      @Basic
      @Column(name = "REFERENCE", length = 30)
      public String getReference() {
      return reference;
      }

      public void setReference(String reference) {
      this.reference = reference;
      }

      @Basic
      @Column(name = "CMT", length = 500)
      public String getCmt() {
      return cmt;
      }

      public void setCmt(String cmt) {
      this.cmt = cmt;
      }

      @Basic
      @Column(name = "STATUS", nullable = false, length = 10)
      public String getStatus() {
      return status;
      }

      public void setStatus(String status) {
      this.status = status;
      }

      @Basic
      @Column(name = "RQMT", nullable = false, length = 10)
      public String getRqmt() {
      return rqmt;
      }

      public void setRqmt(String rqmt) {
      this.rqmt = rqmt;
      }

      @Basic
      @Column(name = "FINAL_APPROVAL_FLAG", nullable = false, length = 1)
      public String getFinalApprovalFlag() {
      return finalApprovalFlag;
      }

      public void setFinalApprovalFlag(String finalApprovalFlag) {
      this.finalApprovalFlag = finalApprovalFlag;
      }

      @Basic
      @Column(name = "CPTY_LN", nullable = false)
      public String getCptyLn() {
      return cptyLn;
      }

      public void setCptyLn(String cptyLn) {
      this.cptyLn = cptyLn;
      }

      public int compareTo(Object o) {
      return 0; //To change body of implemented methods use File | Settings | File Templates.
      }
      }

      The persistence unit is as follows:
      <?xml version="1.0" encoding="UTF-8"?>

      <persistence-unit name="opsmanagerUnit">
      <jta-data-source>java:/OpsTrackingDS</jta-data-source>







      </persistence-unit>