package org.yacos.core.evaluation;

import java.io.Serializable;

import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

public class RatingPK implements Serializable{
	private static final long serialVersionUID = 1L;
	
	
	@ManyToOne(targetEntity=Criterion.class)//,fetch=FetchType.EAGER)
	@JoinColumn(name="criterion_id",nullable=false)
	private Criterion criterion;
	
	@ManyToOne(targetEntity=Report.class)
	@JoinColumn(name="report_id",nullable=false)
	private Report report;

	
	@Override
	public boolean equals(Object obj) {
		if (! (obj instanceof RatingPK) ) {
			return false;
		}
		RatingPK other = (RatingPK) obj;
		return this.criterion.getId().equals(other.criterion.getId()) &&
				this.report.getId() == other.report.getId();
	}
	
	@Override
	public int hashCode() {
		return this.criterion.getId().hashCode() ^ this.report.getId();
	}

	public RatingPK(){
		super();
	}
	
	public RatingPK(Criterion criterion, Report report) {
		super();
		this.criterion = criterion;
		this.report = report;
	}
}
