Subversion Repositories SmartDukaan

Rev

Rev 21717 | Rev 22009 | 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.user;

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

import javax.persistence.Column;
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;

/**
 * This class basically contains address details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name="user.address", schema = "user", uniqueConstraints = {@UniqueConstraint(columnNames = {"name", "line_1", "line_2", "landmark", "city", "state", "pin", "country", "phone"})})
@NamedQueries({
        @NamedQuery(name = "Address.selectCount", query = "select count(a) from Address a where a.retailerId= :retailerId"),
        @NamedQuery(name="Address.selectAll",query="select a from Address a where a.retailerId= :retailerId order by a.updateTimestamp desc"),
        @NamedQuery(name="Address.selectById",query="select a from Address a where a.id= :id"),
        @NamedQuery(name="Address.selectByIds",query="select a from Address a where a.id in :ids"),
        @NamedQuery(name="Address.selectByParams",query="select a from Address a where a.name= :name and a.line1 = :line1 and a.line2 = :line2 and a.landmark = :landmark and a.city = :city and a.state = :state and a.pinCode = :pinCode and a.country = :country and a.phoneNumber = :phoneNumber"),
        @NamedQuery(name="Address.deleteById",query="delete from Address a where a.id= :id"),
})
public class Address implements Serializable{
        
        private static final long serialVersionUID = 1L;
        
        public Address() {
        }
        
        @Id
        @Column(name="id", unique=true, updatable=false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;
        
        @Column(name="name")
        private String name;
        
        @Column(name = "line_1")
        private String line1;
        
        @Column(name = "line_2")
        private String line2;
        
        @Column(name = "landmark")
        private String landmark;
        
        @Column(name = "city")
        private String city;
        
        @Column(name = "state")
        private String state;
        
        @Column(name = "pin", length = 10)
        private String pinCode;
        
        @Column(name = "country", length = 100)
        private String country;
        
        @Column(name = "phone", length = 20)
        private String phoneNumber;
        
        @Column(name = "enabled", columnDefinition="tinyint(1) default 0")
        private boolean enabled;

        @Column(name = "user_id")
        private int retailerId;
        
        @Column(name="added_on", updatable = false)
        private LocalDateTime createTimestamp = LocalDateTime.now();
        
        @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 void setLine1(String line1) {
                this.line1 = line1;
        }
    public String getLine1() {
                return line1;
        }
    public void setLine2(String line2) {
                this.line2 = line2;
        }
    public String getLine2() {
                return line2;
        }
    public void setLandmark(String landmark) {
                this.landmark = landmark;
        }
    public String getLandmark() {
                return landmark;
        }
    public void setCity(String city) {
                this.city = city;
        }
    public String getCity() {
                return city;
        }
    public void setPinCode(String pinCode) {
                this.pinCode = pinCode;
        }
    public String getPinCode() {
                return pinCode;
        }
    public void setState(String state) {
                this.state = state;
        }
    public String getState() {
                return state;
        }
    public void setCountry(String country) {
                this.country = country;
        }
    public String getCountry() {
                return country;
        }
    public void setPhoneNumber(String phoneNumber) {
                this.phoneNumber = phoneNumber;
        }
    public String getPhoneNumber() {
                return phoneNumber;
        }
    public void setEnabled(boolean enabled) {
                this.enabled = enabled;
        }
    public boolean isEnabled() {
                return enabled;
        }
    
    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;
        }
    
        public int getRetaierId() {
                return retailerId;
        }
        public void setRetaierId(int retailerId) {
                this.retailerId = retailerId;
        }
        
        
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((city == null) ? 0 : city.hashCode());
                result = prime * result + ((country == null) ? 0 : country.hashCode());
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + (enabled ? 1231 : 1237);
                result = prime * result + id;
                result = prime * result + ((landmark == null) ? 0 : landmark.hashCode());
                result = prime * result + ((line1 == null) ? 0 : line1.hashCode());
                result = prime * result + ((line2 == null) ? 0 : line2.hashCode());
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
                result = prime * result + ((pinCode == null) ? 0 : pinCode.hashCode());
                result = prime * result + retailerId;
                result = prime * result + ((state == null) ? 0 : state.hashCode());
                result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
                return result;
        }
        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                Address other = (Address) obj;
                if (city == null) {
                        if (other.city != null)
                                return false;
                } else if (!city.equals(other.city))
                        return false;
                if (country == null) {
                        if (other.country != null)
                                return false;
                } else if (!country.equals(other.country))
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (enabled != other.enabled)
                        return false;
                if (id != other.id)
                        return false;
                if (landmark == null) {
                        if (other.landmark != null)
                                return false;
                } else if (!landmark.equals(other.landmark))
                        return false;
                if (line1 == null) {
                        if (other.line1 != null)
                                return false;
                } else if (!line1.equals(other.line1))
                        return false;
                if (line2 == null) {
                        if (other.line2 != null)
                                return false;
                } else if (!line2.equals(other.line2))
                        return false;
                if (name == null) {
                        if (other.name != null)
                                return false;
                } else if (!name.equals(other.name))
                        return false;
                if (phoneNumber == null) {
                        if (other.phoneNumber != null)
                                return false;
                } else if (!phoneNumber.equals(other.phoneNumber))
                        return false;
                if (pinCode == null) {
                        if (other.pinCode != null)
                                return false;
                } else if (!pinCode.equals(other.pinCode))
                        return false;
                if (retailerId != other.retailerId)
                        return false;
                if (state == null) {
                        if (other.state != null)
                                return false;
                } else if (!state.equals(other.state))
                        return false;
                if (updateTimestamp == null) {
                        if (other.updateTimestamp != null)
                                return false;
                } else if (!updateTimestamp.equals(other.updateTimestamp))
                        return false;
                return true;
        }
        @Override
        public String toString() {
                return "Address [id=" + id + ", name=" + name + ", line1=" + line1 + ", line2=" + line2 + ", landmark="
                                + landmark + ", city=" + city + ", state=" + state + ", pinCode=" + pinCode + ", country=" + country
                                + ", phoneNumber=" + phoneNumber + ", enabled=" + enabled + ", createTimestamp=" + createTimestamp
                                + ", updateTimestamp=" + updateTimestamp + "]";
        }
        
    
}