Subversion Repositories SmartDukaan

Rev

Rev 21924 | Rev 22216 | 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.dtr;

import java.io.Serializable;
import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
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.convertor.LocalDateTimeAttributeConverter;

/**
 * This class basically contains api details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name="dtr.shop", schema = "dtr", uniqueConstraints = {@UniqueConstraint(columnNames = {"name","retailer_id", "document_id", "address_id"})})
@NamedQueries({
        @NamedQuery(name = "Shop.selectCount", query = "select count(s) from Shop s"),
        @NamedQuery(name="Shop.selectAll",query="select s from Shop s"),
        @NamedQuery(name="Shop.selectById",query="select s from Shop s where s.id= :id"),
        @NamedQuery(name="Shop.selectByName",query="select s from Shop s where s.name= :name"),
        @NamedQuery(name="Shop.selectByRetailerId",query="select s from Shop s where s.retailerId= :retailerId"),
        @NamedQuery(name="Shop.selectByDocumentId",query="select s from Shop s where s.documentId= :documentId"),
        @NamedQuery(name = "Shop.selectCountByDocumentId", query = "select count(s) from Shop s where s.documentId= :documentId"),
        @NamedQuery(name="Shop.deleteById",query="delete from Shop s where s.id= :id"),
        @NamedQuery(name="Shop.deleteByShopAndRetailerId",query="delete from Shop s where s.id= :id and s.retailerId = :retailerId")
})
public class Shop implements Serializable{
        
        private static final long serialVersionUID = 1L;
        
        public Shop() {
        }
        
        @Id
        @Column(name="id", unique=true, updatable=false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;
        
        @Column(name="name")
        private String name;
        
        @Column(name = "retailer_id")
        private int retailerId;
        
        @Column(name = "document_id")
        private int documentId;
        
        @Column(name = "address_id")
        private int addressId;
        
        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @Column(name="create_timestamp", updatable = false)
        private LocalDateTime createTimestamp = LocalDateTime.now();
        
        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @Column(name="update_timestamp")
        private LocalDateTime updateTimestamp = LocalDateTime.now();
        
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    
    public int getRetailerId() {
                return retailerId;
        }
    public void setRetailerId(int retailerId) {
                this.retailerId = retailerId;
        }
    
    public int getDocumentId() {
                return documentId;
        }
    public void setDocumentId(int documentId) {
                this.documentId = documentId;
        }
    public void setAddressId(int addressId) {
                this.addressId = addressId;
        }
    public int getAddressId() {
                return addressId;
        }
    
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }
    public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }
    
    public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
                this.updateTimestamp = updateTimestamp;
        }
    public LocalDateTime getUpdateTimestamp() {
                return updateTimestamp;
        }
    
    
        @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;
                Shop other = (Shop) obj;
                if (id != other.id)
                        return false;
                return true;
        }
        @Override
        public String toString() {
                return "Shop [id=" + id + ", name=" + name + ", retailerId=" + retailerId + ", documentId=" + documentId
                                + ", addressId=" + addressId + ", createTimestamp=" + createTimestamp + ", updateTimestamp="
                                + updateTimestamp + "]";
        }
    
    
            
}