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.ManyToMany;
12: import javax.persistence.NamedQuery;
13: import javax.persistence.Table;
14: import javax.persistence.Temporal;
15: import javax.persistence.TemporalType;
16:
17: 18: 19: 20: 21:
22: @Entity
23: @Table(name="Song")
24: @NamedQuery(name="Song.list", query="SELECT s FROM Song s")
25: public class Song implements Serializable
26: {
27: private static final long serialVersionUID = 1L;
28:
29: @Id
30: @GeneratedValue(strategy = GenerationType.AUTO)
31: @Column(name="SongID")
32: private Integer SongID;
33: @Column(name="Name")
34: private String Name;
35: @Temporal(TemporalType.DATE)
36: @Column(name="DateCreated")
37: private Date DateCreated;
38:
39: @ManyToMany(mappedBy="Songs")
40: private Collection<Album> Albums;
41:
42: public Song()
43: {
44: super();
45: }
46:
47: public Song(Integer SongID)
48: {
49: super();
50: this.SongID = SongID;
51: }
52:
53: public Integer getSongID()
54: {
55: return SongID;
56: }
57:
58: public void setSongID(Integer SongID)
59: {
60: this.SongID = SongID;
61: }
62:
63: public String getName()
64: {
65: return Name;
66: }
67:
68: public void setName(String Name)
69: {
70: this.Name = Name;
71: }
72:
73: public Date getDateCreated()
74: {
75: return DateCreated;
76: }
77:
78: public void setDateCreated(Date DateCreated)
79: {
80: this.DateCreated = DateCreated;
81: }
82:
83: public Collection<Album> getAlbums()
84: {
85: return Albums;
86: }
87:
88: public void setAlbums(Collection<Album> Albums)
89: {
90: this.Albums = Albums;
91: }
92:
93:
94: @Override
95: public int hashCode()
96: {
97: int hash = 0;
98: hash = (SongID == null ? 0 : SongID.hashCode());
99: return hash;
100: }
101:
102: @Override
103: public boolean equals(Object o)
104: {
105: if( !(o instanceof Song) ) {
106: return false;
107: }
108:
109: Song other = (Song) o;
110: if( ( this.SongID == null && other.SongID != null )
111: || ( this.SongID != null && other.SongID == null )
112: || ( !this.SongID.equals(other.SongID) )
113: ) {
114: return false;
115: }
116: return true;
117: }
118:
119: @Override
120: public String toString()
121: {
122: return "cz.cvut.x33eja.macosond.persistence.entity.Song[id=" + SongID + "]";
123: }
124:
125: }