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

Hibernate example source code file (Lotz.java)

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

column, embeddedid, io, list, lotz, lotz, lotzpk, lotzpk, onetomany, override, prime, prime, serializable, string, string, util

The Hibernate Lotz.java source code

//$Id$
package org.hibernate.test.annotations.manytoone;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

/**
 * @author Emmanuel Bernard
 */
@Entity
public class Lotz implements Serializable {
	@EmbeddedId
	protected LotzPK lotPK;

	@Column( name = "name", nullable = false )
	private String name;

	@Column( name = "location", nullable = false )
	private String location;

	@OneToMany( mappedBy = "lot", fetch = FetchType.LAZY, cascade = CascadeType.ALL )
	private List<Carz> cars;

	public Lotz() {
	}

	public List<Carz> getCars() {
		return this.cars;
	}

	public void setCars(List<Carz> cars) {
		this.cars = cars;
	}

	public String getLocation() {
		return this.location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public LotzPK getLotPK() {
		return this.lotPK;
	}

	public void setLotPK(LotzPK lotPK) {
		this.lotPK = lotPK;
	}

	public String getName() {
		return this.name;
	}

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

	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ( ( this.location == null ) ?
				0 :
				this.location.hashCode() );
		result = PRIME * result + ( ( this.lotPK == null ) ?
				0 :
				this.lotPK.hashCode() );
		result = PRIME * result + ( ( this.name == null ) ?
				0 :
				this.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;
		final Lotz other = (Lotz) obj;
		if ( this.location == null ) {
			if ( other.location != null ) return false;
		}
		else if ( !this.location.equals( other.location ) ) return false;
		if ( this.lotPK == null ) {
			if ( other.lotPK != null ) return false;
		}
		else if ( !this.lotPK.equals( other.lotPK ) ) return false;
		if ( this.name == null ) {
			if ( other.name != null ) return false;
		}
		else if ( !this.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 Lotz.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.