package org.yacos.core.users;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

@Entity
public class Speciality implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;
	private String name;
	
	@ManyToMany(targetEntity=User.class)
	@JoinTable(
		name="speciality_user_map",
		joinColumns=@JoinColumn(name="userId"),
		inverseJoinColumns=@JoinColumn(name="specialityId")
	)
	private List<User> users;
	
	
	public Speciality(String name) {
		super();
		this.name = name;
	}

	public Speciality() {
		super();
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToMany(targetEntity=User.class)
	@JoinTable(
		name="speciality_user_map",
		joinColumns=@JoinColumn(name="userId"),
		inverseJoinColumns=@JoinColumn(name="specialityId")
	)
	public List<User> getUsers() {
		return users;
	}
	
	@ManyToMany(targetEntity=User.class)
	@JoinTable(
		name="speciality_user_map",
		joinColumns=@JoinColumn(name="userId"),
		inverseJoinColumns=@JoinColumn(name="specialityId")
	)
	public void setUsers(List<User> users) {
		this.users = users;
	}
	

}
