001: package org.vraptor.mydvds.model;
002:
003: import java.util.Set;
004:
005: import javax.persistence.Entity;
006: import javax.persistence.EnumType;
007: import javax.persistence.Enumerated;
008: import javax.persistence.GeneratedValue;
009: import javax.persistence.Id;
010: import javax.persistence.ManyToMany;
011:
012: /**
013: * Entidade Dvd.
014: *
015: * A classe representa a tabela dvd no banco de dados.
016: *
017: * Um objeto persistido dessa classe representa um registro no banco de dados.
018: */
019: @Entity
020: public class Dvd {
021:
022: /*
023: * Chave primária.
024: */
025: @Id
026: @GeneratedValue
027: private Long id;
028:
029: private String title;
030:
031: private String description;
032:
033: //Mapeamento entre dvd e usuario
034: @ManyToMany(mappedBy="dvds")
035: private Set<User> users;
036:
037: @Enumerated(EnumType.STRING)
038: private DvdType type;
039:
040: public String getDescription() {
041: return description;
042: }
043:
044: public void setDescription(String description) {
045: this .description = description;
046: }
047:
048: public Long getId() {
049: return id;
050: }
051:
052: public void setId(Long id) {
053: this .id = id;
054: }
055:
056: public String getTitle() {
057: return title;
058: }
059:
060: public void setTitle(String title) {
061: this .title = title;
062: }
063:
064: public DvdType getType() {
065: return type;
066: }
067:
068: public void setType(DvdType type) {
069: this .type = type;
070: }
071:
072: /**
073: * @return the users
074: */
075: public Set<User> getUsers() {
076: return users;
077: }
078:
079: /**
080: * @param users
081: * the users to set
082: */
083: public void setUsers(Set<User> users) {
084: this .users = users;
085: }
086:
087: @Override
088: public boolean equals(Object obj) {
089: return obj instanceof Dvd
090: && getId().equals(((Dvd) obj).getId());
091: }
092:
093: @Override
094: public int hashCode() {
095: if (this .id == null) {
096: return 0;
097: }
098: return this .id.hashCode() * 31;
099: }
100:
101: }
|