-->
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: Help needed in writing a query
PostPosted: Thu May 06, 2010 6:42 am 
Newbie

Joined: Thu May 06, 2010 6:35 am
Posts: 3
Code:
@Entity
@NamedQueries({
   
   @NamedQuery(name="account.forEarnedSms", query="select tx.account FROM EarnedTransaction tx" +
         " WHERE tx.account.group = :group AND tx.year = :year AND tx.quarter = :quarter " +
         "AND (tx.lapsed is null OR tx.lapsed = :lapsed) AND tx.claimDate is null AND tx.claimType is null)"),
   
})
public class Account implements Serializable {

   @Id
   private String msisdn;
   private Date activationDate;
   private Date optInDate;
   private Date optOutDate;
   @Column(name="accountGroup")
   private Integer group;
   
   @Transient
   private Double total;
   
   public String getMsisdn() {
      return msisdn;
   }
   public void setMsisdn(String msisdn) {
      this.msisdn = msisdn;
   }
   public Date getActivationDate() {
      return activationDate;
   }
   public void setActivationDate(Date activationDate) {
      this.activationDate = activationDate;
   }
   public Date getOptInDate() {
      return optInDate;
   }
   public void setOptInDate(Date optInDate) {
      this.optInDate = optInDate;
   }
   public Date getOptOutDate() {
      return optOutDate;
   }
   public void setOptOutDate(Date optOutDate) {
      this.optOutDate = optOutDate;
   }
   public Integer getGroup() {
      return group;
   }
   public void setGroup(Integer group) {
      this.group = group;
   }
   public Double getTotal() {
      return total;
   }
   public void setTotal(Double total) {
      this.total = total;
   }
}

public class EarnedTransaction extends RewardTransaction {

   private static final long serialVersionUID = 3806591283616853649L;
   
   @Enumerated(EnumType.STRING)
   private ClaimType claimType;
   private Date claimDate;
   private String channelId;
   private String agentId;
   private Boolean lapsed;
   
   public ClaimType getClaimType() {
      return claimType;
   }
   public void setClaimType(ClaimType claimType) {
      this.claimType = claimType;
   }
   public Date getClaimDate() {
      return claimDate;
   }
   public void setClaimDate(Date claimDate) {
      this.claimDate = claimDate;
   }
   public String getChannelId() {
      return channelId;
   }
   public void setChannelId(String channelId) {
      this.channelId = channelId;
   }
   public String getAgentId() {
      return agentId;
   }
   public void setAgentId(String agentId) {
      this.agentId = agentId;
   }
   public Boolean getLapsed() {
      return lapsed;
   }
   public void setLapsed(Boolean lapsed) {
      this.lapsed = lapsed;
   }


Now i have to wirte a single !! query such way

The sum return from the below query has to be put in the total(Transient) of Account table
SELECT sum(tx.amount) FROM EarnedTransaction tx WHERE tx.year = :fromYear AND tx.quarter = :fromQuarter AND tx.account.msisdn = :msisdn AND (tx.lapsed is null OR tx.lapsed = :lapsed) AND tx.claimDate is null AND tx.claimType is null"


Please some one help.
Thanks in advance


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.