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

Hibernate example source code file (Contest.java)

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

april, competitor, competitor, february, generatedvalue, id, indexcolumn, month, month, october, october, onetomany, ordercolumn, september

The Hibernate Contest.java source code

//$Id$
package org.hibernate.test.annotations.array;
import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import org.hibernate.annotations.IndexColumn;

/**
 * @author Emmanuel Bernard
 */
@Entity
public class Contest {
	private int id;
	private Competitor[] results;
	private Month[] heldIn;

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@OneToMany(cascade = CascadeType.ALL)
	@OrderColumn(name = "pos")
	public Competitor[] getResults() {
		return results;
	}

	public void setResults(Competitor[] results) {
		this.results = results;
	}
	
	@ElementCollection
	@IndexColumn(name = "pos", base=1) //legacy + base
	public Month[] getHeldIn() {
		return heldIn;
	}

	public void setHeldIn(Month[] heldIn) {
		this.heldIn = heldIn;
	}
	
	public enum Month {
		January, February, March, April, May, June, July, August, September, October, November, December;
	}; 
}

Other Hibernate examples (source code examples)

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