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

Hibernate example source code file (UserPK.java)

This example Hibernate source code file (UserPK.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, column, ctvusers_end_date, ctvusers_key, ctvusers_start_date, date, date, io, long, override, override, serializable, simpledateformat, text, userpk, userpk, util

The Hibernate UserPK.java source code

package org.hibernate.test.annotations.manytoone;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Column;

public class UserPK implements Serializable {
	private static final long serialVersionUID = -7720874756224520523L;
	@Column(name = "CTVUSERS_KEY")
	public Long userKey;

	@Column(name = "CTVUSERS_START_DATE")
	public Date startDate;


	@Column(name = "CTVUSERS_END_DATE")
	public Date endDate;

	public UserPK() {
	}

	@Override
	public boolean equals(Object obj) {
		if ( !( obj instanceof UserPK ) ) {
			return false;
		}
		UserPK userPK = (UserPK) obj;
		SimpleDateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy" );
		return userKey.equals( userPK.userKey ) && formatter.format( startDate )
				.equals( formatter.format( userPK.startDate ) )
				&& formatter.format( endDate ).equals( formatter.format( userPK.endDate ) );
	}

	@Override
	public int hashCode() {
		return userKey.hashCode() * startDate.hashCode() * endDate.hashCode();
	}
}

Other Hibernate examples (source code examples)

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