/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jpa.demo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.MapKeyColumn;
import javax.persistence.OrderBy;
import javax.persistence.OrderColumn;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Administrator
 */
@Entity
public class Student implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    StudentID sid;
    @Temporal(TemporalType.DATE)
    private Date birthday;

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public StudentID getSid() {
        return sid;
    }

    public void setSid(StudentID sid) {
        this.sid = sid;
    }
    private String Name;

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }
    private byte[] portrait;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    public byte[] getPortrait() {
        return portrait;
    }

    public void setPortrait(byte[] portrait) {
        this.portrait = portrait;
    }
    private String meno;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    public String getMeno() {
        return meno;
    }

    public void setMeno(String meno) {
        this.meno = meno;
    }
    @ElementCollection
    private Set<String> hobbies;

    public Set<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(Set<String> hobbies) {
        this.hobbies = hobbies;
    }

    public List<String> getContactor() {
        return Contactor;
    }

    public void setContactor(List<String> Contactor) {
        this.Contactor = Contactor;
    }

    public Map<String, String> getScores() {
        return scores;
    }

    public void setScores(Map<String, String> scores) {
        this.scores = scores;
    }
    @ElementCollection
    @OrderColumn(name="con_ORDER")
    private List<String> Contactor;
    @ElementCollection
    @CollectionTable(name = "Scores")
    @MapKeyColumn(name = "subject")
    @Column(name = "score")
    private Map<String, String> scores;

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Student)) {
            return false;
        }
        Student other = (Student) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jpa.demo.Student[ id=" + sid + " ]";
    }
    private StudentType type;
	@Enumerated(EnumType.STRING)
	public StudentType getType() {
		return type;
	}
	public void setType(StudentType type) {
		this.type = type;
	}
	public enum StudentType {
		common, special
	}
    
      
}
