Subversion Repositories SmartDukaan

Rev

Rev 21924 | Rev 22925 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.fofo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.spice.profitmandi.dao.enumuration.fofo.PaymentOptionType;

/**
 * This class basically contains api details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name="fofo.payment_option", schema = "fofo", uniqueConstraints = {@UniqueConstraint(columnNames = {"order_id","type"})})
@NamedQueries({
        @NamedQuery(name = "PaymentOption.selectById", query = "select po from PaymentOption po where po.id = :id"),
        @NamedQuery(name = "PaymentOption.selectByOrderId", query = "select po from PaymentOption po where po.orderId = :orderId"),
        @NamedQuery(name = "PaymentOption.selectTotalAmountByType", query = "select sum(po.amount) from PaymentOption po where po.type = :type group by po.type"),
        @NamedQuery(name = "PaymentOption.selectTotalAmountByOrderId", query = "select sum(po.amount) from PaymentOption po where po.orderId = :orderId group by po.orderId")
})
public class PaymentOption implements Serializable{
        
        private static final long serialVersionUID = 1L;
        
        public PaymentOption() {
        }
        
        @Id
        @Column(name="id")
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;
        
        @Column(name = "order_id")
        private int orderId;
        
        @Enumerated(EnumType.STRING)
        @Column(name = "type")
        private PaymentOptionType type;
        
        @Column(name = "amount")
        private float amount;
        
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public int getOrderId() {
                return orderId;
        }
        public void setOrderId(int orderId) {
                this.orderId = orderId;
        }
        public PaymentOptionType getType() {
                return type;
        }
        public void setType(PaymentOptionType type) {
                this.type = type;
        }
        public float getAmount() {
                return amount;
        }
        public void setAmount(float amount) {
                this.amount = amount;
        }
        
        
        
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + id;
                return result;
        }
        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                PaymentOption other = (PaymentOption) obj;
                if (id != other.id)
                        return false;
                return true;
        }
        @Override
        public String toString() {
                return "PaymentOption [id=" + id + ", orderId=" + orderId + ", type=" + type + ", amount=" + amount + "]";
        }
        
        
        
}