Subversion Repositories SmartDukaan

Rev

Rev 26776 | Rev 26779 | 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 java.time.LocalDateTime;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;

/**
 * This class basically contains  details
 * 
 * @author ashikali
 *
 */
/**
 * @author amit
 *
 */
@Entity
@Table(name="fofo.customer", schema = "fofo")
@NamedQueries({
        @NamedQuery(name="Customer.selectById",query="select c from Customer c where c.id= :id")
})
public class Customer implements Serializable{
        
        private static final long serialVersionUID = 1L;
        
        public Customer() {
        }
        
        @Id
        @Column(name="id")
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;
        
        @Column(name = "first_name", length = 20)
        private String firstName;
        
        @Column(name = "last_name", length = 20)
        private String lastName;
        
        @Column(name="email_id", length = 20)
        private String emailId;
        
        @Column(name="mobile_number", length = 20)
        private String mobileNumber;
        
        @Column(name="password")
        @JsonIgnore
        private String password;
        

        @Transient
        private boolean passwordExist;
        
        public boolean isPasswordExist() {
                return passwordExist;
        }
        public void setPasswordExist(boolean passwordExist) {
                this.passwordExist = passwordExist;
        }
        public String getPassword() {
                return password;
        }
        public void setPassword(String password) {
                this.password = password;
        }
        public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }
        public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @Column(name = "create_timestamp")
        private LocalDateTime createTimestamp = LocalDateTime.now();

        @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
        @JoinColumn(name="customer_id",insertable=false,updatable=false,nullable=false)
        @JsonIgnore
        private List<CustomerAddress> customerAddress;  
        
        public List<CustomerAddress> getCustomerAddress() {
                return customerAddress;
        }
        public void setCustomerAddress(List<CustomerAddress> customerAddress) {
                this.customerAddress = customerAddress;
        }
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        
        public String getFirstName() {
                return firstName;
        }
        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }
        
        public String getLastName() {
                return lastName;
        }
        public void setLastName(String lastName) {
                this.lastName = lastName;
        }
        
        public String getEmailId() {
                return emailId;
        }
        public void setEmailId(String emailId) {
                this.emailId = emailId;
        }
        
        public String getMobileNumber() {
                return mobileNumber;
        }
        public void setMobileNumber(String mobileNumber) {
                this.mobileNumber = mobileNumber;
        }
        
        
        
        @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;
                Customer other = (Customer) obj;
                if (id != other.id)
                        return false;
                return true;
        }
        @Override
        public String toString() {
                return "Customer [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", emailId=" + emailId 
                                + ", mobileNumber=" + mobileNumber + ", createTimestamp=" + createTimestamp + ", customerAddress=" 
                                + customerAddress + "]";
        }
        
        
}