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

Hibernate example source code file (Country.java)

This example Hibernate source code file (Country.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, column, country, country, entity, id, integer, integer, override, override, string, string, suppresswarnings, unuseddeclaration

The Hibernate Country.java source code

package org.hibernate.envers.test.integration.accesstype;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.envers.Audited;

@Entity
@Audited
public class Country {
	@Id
	@Column(length = 4)
	private Integer code;

	@Column(length = 40)
	private String name;

	/**
	 * Default constructor for persistence provider.
	 */
	@SuppressWarnings({"UnusedDeclaration"})
	private Country() { }

	private Country(Integer code, String naam) {
		this.code = code;
		this.name = naam;
	}

	public Integer getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public static Country of(Integer code, String name) {
		return new Country(code, name);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Country other = (Country) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}

Other Hibernate examples (source code examples)

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