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

Hibernate example source code file (PlanetCheatSheet.java)

This example Hibernate source code file (PlanetCheatSheet.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, entity, id, planet, planet, planetcheatsheet, planetcheatsheet, string, string, tab, tab

The Hibernate PlanetCheatSheet.java source code

package org.hibernate.test.annotations.id.sequences.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;


/**
 * Test entity for enum type as id.
 * 
 * @author Hardy Ferentschik
 * @see ANN-744
 */
@Entity
public class PlanetCheatSheet {

	@Id
	@Enumerated(EnumType.STRING)
	@Column(name = "planet")
	private Planet planet;

	private double mass;

	private double radius;

	private long numberOfInhabitants;

	public Planet getPlanet() {
		return planet;
	}

	public void setPlanet(Planet planet) {
		this.planet = planet;
	}

	public double getMass() {
		return mass;
	}

	public void setMass(double mass) {
		this.mass = mass;
	}

	public double getRadius() {
		return radius;
	}

	public void setRadius(double radius) {
		this.radius = radius;
	}

	public long getNumberOfInhabitants() {
		return numberOfInhabitants;
	}

	public void setNumberOfInhabitants(long numberOfInhabitants) {
		this.numberOfInhabitants = numberOfInhabitants;
	}

	/**
	 * Constructs a <code>String with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "PlanetCheatSheet ( "
	        + super.toString() + TAB
	        + "planet = " + this.planet + TAB
	        + "mass = " + this.mass + TAB
	        + "radius = " + this.radius + TAB
	        + "numberOfInhabitants = " + this.numberOfInhabitants + TAB
	        + " )";
	
	    return retValue;
	}	
}

Other Hibernate examples (source code examples)

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