-->
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: HQL Query
PostPosted: Mon Sep 07, 2009 3:09 am 
Newbie

Joined: Mon Sep 07, 2009 3:05 am
Posts: 2
Hi I have two three entities

Entity Customer

Code:
@Entity
@DiscriminatorValue("customer")
@Name("customer")
public class Customer extends Person implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = -22078731036388186L;   
   
   private List<Invoice> invoices;
   private List<CustomerTransaction> customerTransactions;
   private String brandname;
   private String statusImage;
   
   public Customer() {}
   
   
   @Column(unique=true)
   public String getBrandname() {
      return brandname;
   }
   public void setBrandname(String brandname) {
      this.brandname = brandname;
   }
   
   @OneToMany
   public List<Invoice> getInvoices() {
      return invoices;
   }
   public void setInvoices(List<Invoice> invoices) {
      this.invoices = invoices;
   }
   
   @OneToMany
   public List<CustomerTransaction> getCustomerTransactions() {
      return customerTransactions;
   }
   public void setCustomerTransactions(
         List<CustomerTransaction> customerTransactions) {
      this.customerTransactions = customerTransactions;
   }
   
   @Transient
   public void addInvoice(Invoice inv) {
      
      if(this.invoices==null) {
         invoices=new ArrayList<Invoice>();
      }
      
      invoices.add(inv);
      
      
   }
   
   @Transient
   public void addTransaction(CustomerTransaction tran) {
      if(this.customerTransactions==null) {
         customerTransactions=new ArrayList<CustomerTransaction>();
      }
      
      customerTransactions.add(tran);
      
   }

   @Override
   public String toString() {
      // TODO Auto-generated method stub
      return this.brandname;
   }

   @Transient
   public String getStatusImage() {
      return statusImage;
   }


   public void setStatusImage(String statusImage) {
      this.statusImage = statusImage;
   }
   
   
}



Entity Transactions

Code:
@Entity
public class CustomerTransaction implements Serializable{

   /**
    *
    */
   private static final long serialVersionUID = -7177554785463001529L;
   
   private long id;
   private double amount;
   private String description;
   private Date date;
   
   @Id @GeneratedValue
   public long getId() {
      return id;
   }
   public void setId(long id) {
      this.id = id;
   }
   public double getAmount() {
      return amount;
   }
   public void setAmount(double amount) {
      this.amount = amount;
   }
   public String getDescription() {
      return description;
   }
   public void setDescription(String description) {
      this.description = description;
   }
   public Date getDate() {
      return date;
   }
   public void setDate(Date date) {
      this.date = date;
   }
   
   
}



Entity Invoice

Code:
@Entity
public class Invoice implements Serializable{

   /**
    *
    */
   private static final long serialVersionUID = 1510168101209093640L;
   
   

   
   @OneToMany
   public List<InvoiceDetails> getInvoiceDetails() {
      return invoiceDetails;
   }
   public void setInvoiceDetails(List<InvoiceDetails> invoiceDetails) {
      this.invoiceDetails = invoiceDetails;
   }
   private long id;
   private Date date;
   private double amount;
   private float fpa;
   private int invoiceState=0;
    private List<InvoiceDetails> invoiceDetails;
   
   @Id @GeneratedValue
   public long getId() {
      return id;
   }
   public void setId(long id) {
      this.id = id;
   }
   public Date getDate() {
      return date;
   }
   public void setDate(Date date) {
      this.date = date;
   }
   public double getAmount() {
      return amount;
   }
   public void setAmount(double amount) {
      this.amount = amount;
   }
   public float getFpa() {
      return fpa;
   }
   public void setFpa(float fpa) {
      this.fpa = fpa;
   }
   
   @NotNull
   public int getInvoiceState() {
      return invoiceState;
   }
   public void setInvoiceState(int state) {
      this.invoiceState = state;
   }
   
}



how can I retrieve the customers that the invoice total amount is bigger than the transaction total amount?


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.