alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (WikiPage.java)

This example Hibernate source code file (WikiPage.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

audited, basic, generatedvalue, hashset, id, long, override, override, set, set, string, string, util, wikipage, wikipage

The Hibernate WikiPage.java source code

package org.hibernate.envers.test.integration.hashcode;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import org.hibernate.envers.Audited;

/**
 * @author Adam Warski (adam at warski dot org)
 */
@Entity
@Audited
public class WikiPage {
	@Id
	@GeneratedValue
	private Long id;

	@Basic
	private String title;

	@Basic
	private String content;

	@ElementCollection
	private Set<String> links = new HashSet();

	@OneToMany
	private Set<WikiImage> images = new HashSet();

	public WikiPage() {
	}

	public WikiPage(String title, String content) {
		this.title = title;
		this.content = content;
	}

	public Long getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Set<String> getLinks() {
		return links;
	}

	public void setLinks(Set<String> links) {
		this.links = links;
	}

	public Set<WikiImage> getImages() {
		return images;
	}

	public void setImages(Set<WikiImage> images) {
		this.images = images;
	}

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

		WikiPage wikiPage = (WikiPage) o;

		if (content != null ? !content.equals(wikiPage.content) : wikiPage.content != null) return false;
		if (title != null ? !title.equals(wikiPage.title) : wikiPage.title != null) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = title != null ? title.hashCode() : 0;
		result = 31 * result + (content != null ? content.hashCode() : 0);
		return result;
	}

	@Override
	public String toString() {
		return "WikiPage{" +
				"title='" + title + '\'' +
				", content='" + content + '\'' +
				", links=" + links +
				", images=" + images +
				'}';
	}
}

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate WikiPage.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.