/*** * Copyright (c) 2009 Caelum - www.caelum.com.br/opensource * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package br.com.caelum.vraptor.mydvds.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; @Entity public class DvdRental { @Id @GeneratedValue private Long id; @ManyToOne private User owner; @ManyToOne private Dvd dvd; public DvdRental(User owner, Dvd dvd) { this.owner = owner; this.dvd = dvd; } public DvdRental() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public User getOwner() { return owner; } public void setOwner(User owner) { this.owner = owner; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((dvd == null) ? 0 : dvd.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((owner == null) ? 0 : owner.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; } DvdRental other = (DvdRental) obj; if (dvd == null) { if (other.dvd != null) { return false; } } else if (!dvd.equals(other.dvd)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (owner == null) { if (other.owner != null) { return false; } } else if (!owner.equals(other.owner)) { return false; } return true; } public Dvd getDvd() { return dvd; } public void setDvd(Dvd dvd) { this.dvd = dvd; } }