Entry 770

Something

   

Submitted by anonymous on May 12, 2008 at 2:22 a.m.
Language: Java. Code size: 2.6 KB.

package com.strutscasts.model;



import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.persistence.*;
import java.util.Set;

/**
 * User: dusty
 * Date: May 7, 2008
 */
@Entity
public class Episode {
    @Id @GeneratedValue
    private Long id;
    private String name;
    private Integer episodeNumber;
    private String episodeDate;
    private String description;

    @OneToMany(mappedBy = "episode",cascade = CascadeType.ALL)
    private Set<Comment> comments;

    private static Log log = LogFactory.getLog(Episode.class);


    public void addComment(Comment comment){
        this.comments.add(comment);
        comment.setEpisode(this);
    }

    public void removeComment(Comment comment){
        this.comments.remove(comment);
        comment.setEpisode(null);
    }
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getEpisodeNumber() {
        return episodeNumber;
    }

    public void setEpisodeNumber(Integer episodeNumber) {
        this.episodeNumber = episodeNumber;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    public Set<Comment> getComments() {
        return comments;
    }

    public void setComments(Set<Comment> comments) {
        this.comments = comments;
    }

    public String getEpisodeDate() {
        return episodeDate;
    }

    public void setEpisodeDate(String episodeDate) {
        this.episodeDate = episodeDate;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Episode)) return false;

        Episode episode = (Episode) o;

        if (episodeNumber != episode.episodeNumber) return false;
        if (name != null ? !name.equals(episode.name) : episode.name != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (name != null ? name.hashCode() : 0);
        result = 31 * result + episodeNumber;
        result = 31 * result + (description != null ? description.hashCode() : 0);
        return result;
    }



    public String toString() {
        return "Episode{" +
                "name='" + name + '\'' +
                ", episodeNumber=" + episodeNumber +
                ", description='" + description + '\'' +
                '}';
    }


}

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).