package com.riskvis.entity;

// Generated May 12, 2014 11:45:38 PM by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Transports generated by hbm2java
 */
@Entity
@Table(name = "transports", catalog = "test")
public class Transports extends AbstractEntity implements java.io.Serializable {

	private static final long serialVersionUID = -2787847957235299023L;
	private Integer idtransports;
	private String name;
	private String description;
	private byte[] icon;
	private Set<PlacesHasTransports> placesHasTransportses = new HashSet<PlacesHasTransports>(
			0);
	private Set<Transportationrisks> transportationriskses = new HashSet<Transportationrisks>(
			0);

	public Transports() {
	}

	public Transports(String name) {
		this.name = name;
	}

	public Transports(String name, String description, byte[] icon,
			Set<PlacesHasTransports> placesHasTransportses,
			Set<Transportationrisks> transportationriskses) {
		this.name = name;
		this.description = description;
		this.icon = icon;
		this.placesHasTransportses = placesHasTransportses;
		this.transportationriskses = transportationriskses;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idtransports", unique = true, nullable = false)
	public Integer getIdtransports() {
		return this.idtransports;
	}

	public void setIdtransports(Integer idtransports) {
		this.idtransports = idtransports;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

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

	@Column(name = "description", length = 512)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "icon")
	public byte[] getIcon() {
		return this.icon;
	}

	public void setIcon(byte[] icon) {
		this.icon = icon;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "transports")
	public Set<PlacesHasTransports> getPlacesHasTransportses() {
		return this.placesHasTransportses;
	}

	public void setPlacesHasTransportses(
			Set<PlacesHasTransports> placesHasTransportses) {
		this.placesHasTransportses = placesHasTransportses;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "transports")
	@Cascade({ CascadeType.DELETE })
	public Set<Transportationrisks> getTransportationriskses() {
		return this.transportationriskses;
	}

	public void setTransportationriskses(
			Set<Transportationrisks> transportationriskses) {
		this.transportationriskses = transportationriskses;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((idtransports == null) ? 0 : idtransports.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;
		Transports other = (Transports) obj;
		if (idtransports == null) {
			if (other.idtransports != null)
				return false;
		} else if (!idtransports.equals(other.idtransports))
			return false;
		return true;
	}

}
