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

Hibernate example source code file (Passport.java)

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

arraylist, arraylist, collection, collection, collection_id, collectionid, column, column, jointable, long, manytomany, string, string, tablegenerator, util

The Hibernate Passport.java source code

//$Id$
package org.hibernate.test.annotations.identifiercollection;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.TableGenerator;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.Type;

/**
 * @author Emmanuel Bernard
 */
@Entity
@TableGenerator(name="ids_generator", table="IDS")
public class Passport {
	@Id @GeneratedValue @Column(name="passport_id") private Long id;
	private String name;

	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name="PASSPORT_STAMP")
	@CollectionId(columns = @Column(name="COLLECTION_ID"), type=@Type(type="long"), generator = "generator")
	@TableGenerator(name="generator", table="IDSTAMP")
	private Collection<Stamp> stamps = new ArrayList();

	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name="PASSPORT_VISASTAMP")
	@CollectionId(columns = @Column(name="COLLECTION_ID"), type=@Type(type="long"), generator = "ids_generator")
	//TODO test identity generator
	private Collection<Stamp> visaStamp = new ArrayList();

	public Long getId() {
		return id;
	}

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

	public String getName() {
		return name;
	}

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

	public Collection<Stamp> getStamps() {
		return stamps;
	}

	public void setStamps(Collection<Stamp> stamps) {
		this.stamps = stamps;
	}

	public Collection<Stamp> getVisaStamp() {
		return visaStamp;
	}

	public void setVisaStamp(Collection<Stamp> visaStamp) {
		this.visaStamp = visaStamp;
	}
}

Other Hibernate examples (source code examples)

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