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

Hibernate example source code file (Footballer.java)

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

discriminatorcolumn, entity, entity, footballer, footballer, id, id, string, string

The Hibernate Footballer.java source code

//$Id: Footballer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
package org.hibernate.test.annotations.id.sequences.entities;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

/**
 * @author Emmanuel Bernard
 */
@Entity
@IdClass(FootballerPk.class)
@DiscriminatorColumn(name = "bibi")
public class Footballer {
	private String firstname;
	private String lastname;
	private String club;

	public Footballer() {
	}

	public Footballer(String firstname, String lastname, String club) {
		this.firstname = firstname;
		this.lastname = lastname;
		this.club = club;
	}

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

		final Footballer footballer = (Footballer) o;

		if ( !firstname.equals( footballer.firstname ) ) return false;
		if ( !lastname.equals( footballer.lastname ) ) return false;

		return true;
	}

	public int hashCode() {
		int result;
		result = firstname.hashCode();
		result = 29 * result + lastname.hashCode();
		return result;
	}

	@Id
	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	@Id
	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getClub() {
		return club;
	}

	public void setClub(String club) {
		this.club = club;
	}
}

Other Hibernate examples (source code examples)

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