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

Hibernate example source code file (Category.java)

This example Hibernate source code file (Category.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

category, category, date, date, long, long, set, string, string, util

The Hibernate Category.java source code

// $Id: Category.java 6507 2005-04-25 16:57:32Z steveebersole $
package org.hibernate.test.filter;
import java.util.Date;
import java.util.Set;

/**
 * Implementation of Category.
 *
 * @author Steve Ebersole
 */
public class Category {
	private Long id;
	private String name;
	private Date effectiveStartDate;
	private Date effectiveEndDate;
	private Set products;

	public Category() {
	}

	public Category(String name) {
		this.name = name;
	}

	public Category(String name, Date effectiveStartDate, Date effectiveEndDate) {
		this.name = name;
		this.effectiveStartDate = effectiveStartDate;
		this.effectiveEndDate = effectiveEndDate;
	}

	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 Date getEffectiveStartDate() {
		return effectiveStartDate;
	}

	public void setEffectiveStartDate(Date effectiveStartDate) {
		this.effectiveStartDate = effectiveStartDate;
	}

	public Date getEffectiveEndDate() {
		return effectiveEndDate;
	}

	public void setEffectiveEndDate(Date effectiveEndDate) {
		this.effectiveEndDate = effectiveEndDate;
	}

	public Set getProducts() {
		return products;
	}

	public void setProducts(Set products) {
		this.products = products;
	}

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

		final Category category = ( Category ) o;

		if ( !name.equals( category.name ) ) {
			return false;
		}

		if ( effectiveEndDate != null ?
		        !effectiveEndDate.equals( category.effectiveEndDate ) :
		        category.effectiveEndDate != null ) {
			return false;
		}

		if ( effectiveStartDate != null ?
		        !effectiveStartDate.equals( category.effectiveStartDate ) :
		        category.effectiveStartDate != null ) {
			return false;
		}

		return true;
	}

	public int hashCode() {
		int result;
		result = name.hashCode();
		result = 29 * result + ( effectiveStartDate != null ? effectiveStartDate.hashCode() : 0 );
		result = 29 * result + ( effectiveEndDate != null ? effectiveEndDate.hashCode() : 0 );
		return result;
	}
}

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate Category.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.