1: package cz.cvut.x33eja.macosond.persistence.entity;
2:
3: import java.io.Serializable;
4: import java.util.Collection;
5: import java.util.Date;
6: import javax.persistence.Column;
7: import javax.persistence.Entity;
8: import javax.persistence.GeneratedValue;
9: import javax.persistence.GenerationType;
10: import javax.persistence.Id;
11: import javax.persistence.JoinColumn;
12: import javax.persistence.JoinTable;
13: import javax.persistence.ManyToMany;
14: import javax.persistence.ManyToOne;
15: import javax.persistence.NamedQuery;
16: import javax.persistence.Table;
17: import javax.persistence.Temporal;
18: import javax.persistence.TemporalType;
19:
20: 21: 22: 23: 24:
25: @Entity
26: @Table(name="Album")
27: @NamedQuery(name="Album.list", query="SELECT a FROM Album a")
28: public class Album implements Serializable
29: {
30: private static final long serialVersionUID = 1L;
31:
32: @Id
33: @GeneratedValue(strategy = GenerationType.AUTO)
34: @Column(name="AlbumID")
35: private Integer AlbumID;
36: @Column(name="Name")
37: private String Name;
38: @Temporal(TemporalType.DATE)
39: @Column(name="DateReleased")
40: private Date DateReleased;
41: @Temporal(TemporalType.DATE)
42: @Column(name="DateRecorded")
43: private Date DateRecorded;
44: @Column(name="AudioLength")
45: private Integer AudioLength;
46: @ManyToOne
47: @JoinColumn(name="Genre")
48: private Genre Genre;
49:
50: @ManyToMany
51: @JoinTable(
52: name = "AlbumSong",
53: joinColumns = @JoinColumn(name="AlbumID", referencedColumnName="AlbumID"),
54: inverseJoinColumns = @JoinColumn(name="SongID", referencedColumnName="SongID")
55: )
56: private Collection<Song> Songs;
57:
58: public Album()
59: {
60: super();
61: }
62:
63: public Album(Integer AlbumID)
64: {
65: super();
66: this.AlbumID = AlbumID;
67: }
68:
69: public Integer getAlbumID()
70: {
71: return AlbumID;
72: }
73:
74: public void setAlbumID(Integer AlbumID)
75: {
76: this.AlbumID = AlbumID;
77: }
78:
79: public String getName()
80: {
81: return Name;
82: }
83:
84: public void setName(String Name)
85: {
86: this.Name = Name;
87: }
88:
89: public Date getDateReleased()
90: {
91: return DateReleased;
92: }
93:
94: public void setDateReleased(Date DateReleased)
95: {
96: this.DateReleased = DateReleased;
97: }
98:
99: public Date getDateRecorded()
100: {
101: return DateRecorded;
102: }
103:
104: public void setDateRecorded(Date DateRecorded)
105: {
106: this.DateRecorded = DateRecorded;
107: }
108:
109: public Integer getAudioLength()
110: {
111: return AudioLength;
112: }
113:
114: public void setAudioLength(Integer AudioLength)
115: {
116: this.AudioLength = AudioLength;
117: }
118:
119: public Genre getGenre()
120: {
121: return Genre;
122: }
123:
124: public void setGenre(Genre Genre)
125: {
126: this.Genre = Genre;
127: }
128:
129: public Collection<Song> getSongs()
130: {
131: return Songs;
132: }
133:
134: public void setSongs(Collection<Song> Songs)
135: {
136: this.Songs = Songs;
137: }
138:
139: @Override
140: public int hashCode()
141: {
142: int hash = 0;
143: hash = (AlbumID == null ? 0 : AlbumID.hashCode());
144: return hash;
145: }
146:
147: @Override
148: public boolean equals(Object o)
149: {
150: if( !(o instanceof Album) ) {
151: return false;
152: }
153:
154: Album other = (Album) o;
155: if( ( this.AlbumID == null && other.AlbumID != null )
156: || ( this.AlbumID != null && other.AlbumID == null )
157: || ( !this.AlbumID.equals(other.AlbumID) )
158: ) {
159: return false;
160: }
161: return true;
162: }
163:
164: @Override
165: public String toString()
166: {
167: return "cz.cvut.x33eja.macosond.persistence.entity.Album[id=" + AlbumID + "]";
168: }
169:
170: }