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?