FileDocCategorySizeDatePackage
Hibernate.javaAPI DocHibernate 3.2.513843Fri Jun 09 22:24:06 BST 2006org.hibernate

Hibernate

public final class Hibernate extends Object
  • Provides access to the full range of Hibernate built-in types. Type instances may be used to bind values to query parameters.
  • A factory for new Blobs and Clobs.
  • Defines static methods for manipulation of proxies.
author
Gavin King
see
java.sql.Clob
see
java.sql.Blob
see
org.hibernate.type.Type

Fields Summary
public static final org.hibernate.type.NullableType
LONG
Hibernate long type.
public static final org.hibernate.type.NullableType
SHORT
Hibernate short type.
public static final org.hibernate.type.NullableType
INTEGER
Hibernate integer type.
public static final org.hibernate.type.NullableType
BYTE
Hibernate byte type.
public static final org.hibernate.type.NullableType
FLOAT
Hibernate float type.
public static final org.hibernate.type.NullableType
DOUBLE
Hibernate double type.
public static final org.hibernate.type.NullableType
CHARACTER
Hibernate character type.
public static final org.hibernate.type.NullableType
STRING
Hibernate string type.
public static final org.hibernate.type.NullableType
TIME
Hibernate time type.
public static final org.hibernate.type.NullableType
DATE
Hibernate date type.
public static final org.hibernate.type.NullableType
TIMESTAMP
Hibernate timestamp type.
public static final org.hibernate.type.NullableType
BOOLEAN
Hibernate boolean type.
public static final org.hibernate.type.NullableType
TRUE_FALSE
Hibernate true_false type.
public static final org.hibernate.type.NullableType
YES_NO
Hibernate yes_no type.
public static final org.hibernate.type.NullableType
BIG_DECIMAL
Hibernate big_decimal type.
public static final org.hibernate.type.NullableType
BIG_INTEGER
Hibernate big_integer type.
public static final org.hibernate.type.NullableType
BINARY
Hibernate binary type.
public static final org.hibernate.type.NullableType
WRAPPER_BINARY
Hibernate wrapper-binary type.
public static final org.hibernate.type.NullableType
CHAR_ARRAY
Hibernate char[] type.
public static final org.hibernate.type.NullableType
CHARACTER_ARRAY
Hibernate Character[] type.
public static final org.hibernate.type.NullableType
TEXT
Hibernate text type.
public static final org.hibernate.type.Type
BLOB
Hibernate blob type.
public static final org.hibernate.type.Type
CLOB
Hibernate clob type.
public static final org.hibernate.type.NullableType
CALENDAR
Hibernate calendar type.
public static final org.hibernate.type.NullableType
CALENDAR_DATE
Hibernate calendar_date type.
public static final org.hibernate.type.NullableType
LOCALE
Hibernate locale type.
public static final org.hibernate.type.NullableType
CURRENCY
Hibernate currency type.
public static final org.hibernate.type.NullableType
TIMEZONE
Hibernate timezone type.
public static final org.hibernate.type.NullableType
CLASS
Hibernate class type.
public static final org.hibernate.type.NullableType
SERIALIZABLE
Hibernate serializable type.
public static final org.hibernate.type.Type
OBJECT
Hibernate object type.
Constructors Summary
private Hibernate()
Cannot be instantiated.



	   	 
	  
		throw new UnsupportedOperationException();
	
Methods Summary
public static org.hibernate.type.Typeany(org.hibernate.type.Type metaType, org.hibernate.type.Type identifierType)
A Hibernate any type.

param
metaType a type mapping java.lang.Class to a single column
param
identifierType the entity identifier type
return
the Type

		return new AnyType( metaType, identifierType );
	
public static voidclose(java.util.Iterator iterator)
Close an Iterator created by iterate() immediately, instead of waiting until the session is closed or disconnected.

param
iterator an Iterator created by iterate()
throws
HibernateException
see
org.hibernate.Query#iterate
see
Query#iterate()

		if ( iterator instanceof HibernateIterator ) {
			( ( HibernateIterator ) iterator ).close();
		}
		else {
			throw new IllegalArgumentException( "not a Hibernate iterator" );
		}
	
public static java.sql.BlobcreateBlob(byte[] bytes)
Create a new Blob. The returned object will be initially immutable.

param
bytes a byte array
return
the Blob

		return new SerializableBlob( new BlobImpl( bytes ) );
	
public static java.sql.BlobcreateBlob(java.io.InputStream stream, int length)
Create a new Blob. The returned object will be initially immutable.

param
stream a binary stream
param
length the number of bytes in the stream
return
the Blob

		return new SerializableBlob( new BlobImpl( stream, length ) );
	
public static java.sql.BlobcreateBlob(java.io.InputStream stream)
Create a new Blob. The returned object will be initially immutable.

param
stream a binary stream
return
the Blob
throws
IOException

		return new SerializableBlob( new BlobImpl( stream, stream.available() ) );
	
public static java.sql.ClobcreateClob(java.lang.String string)
Create a new Clob. The returned object will be initially immutable.

param
string a String

		return new SerializableClob( new ClobImpl( string ) );
	
public static java.sql.ClobcreateClob(java.io.Reader reader, int length)
Create a new Clob. The returned object will be initially immutable.

param
reader a character stream
param
length the number of characters in the stream

		return new SerializableClob( new ClobImpl( reader, length ) );
	
public static org.hibernate.type.Typecustom(java.lang.Class userTypeClass)
A Hibernate custom type.

param
userTypeClass a class that implements UserType

		return custom( userTypeClass, null );
	
public static org.hibernate.type.Typecustom(java.lang.Class userTypeClass, java.lang.String[] parameterNames, java.lang.String[] parameterValues)
A Hibernate parameterizable custom type.

param
userTypeClass a class that implements UserType and ParameterizableType
param
parameterNames the names of the parameters passed to the type
param
parameterValues the values of the parameters passed to the type. They must match up with the order and length of the parameterNames array.

		Properties parameters = new Properties();
		for ( int i = 0; i < parameterNames.length; i++ ) {
			parameters.setProperty( parameterNames[i], parameterValues[i] );
		}
		return custom( userTypeClass, parameters );
	
public static org.hibernate.type.Typecustom(java.lang.Class userTypeClass, java.util.Properties parameters)
A Hibernate parameterizable custom type.

param
userTypeClass a class that implements UserType and ParameterizableType
param
parameters the parameters as a collection of name/value pairs

		if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) {
			CompositeCustomType type = new CompositeCustomType( userTypeClass, parameters );
			return type;
		}
		else {
			CustomType type = new CustomType( userTypeClass, parameters );
			return type;
		}
	
public static org.hibernate.type.Typeentity(java.lang.Class persistentClass)
A Hibernate persistent object (entity) type.

param
persistentClass a mapped entity class

		// not really a many-to-one association *necessarily*
		return new ManyToOneType( persistentClass.getName() );
	
public static org.hibernate.type.Typeentity(java.lang.String entityName)
A Hibernate persistent object (entity) type.

param
entityName a mapped entity class

		// not really a many-to-one association *necessarily*
		return new ManyToOneType( entityName );
	
public static java.lang.ClassgetClass(java.lang.Object proxy)
Get the true, underlying class of a proxied persistent class. This operation will initialize a proxy by side-effect.

param
proxy a persistable object or proxy
return
the true class of the instance
throws
HibernateException

		if ( proxy instanceof HibernateProxy ) {
			return ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer()
					.getImplementation()
					.getClass();
		}
		else {
			return proxy.getClass();
		}
	
public static voidinitialize(java.lang.Object proxy)
Force initialization of a proxy or persistent collection.

Note: This only ensures intialization of a proxy object or collection; it is not guaranteed that the elements INSIDE the collection will be initialized/materialized.

param
proxy a persistable object, proxy, persistent collection or null
throws
HibernateException if we can't initialize the proxy at this time, eg. the Session was closed

		if ( proxy == null ) {
			return;
		}
		else if ( proxy instanceof HibernateProxy ) {
			( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().initialize();
		}
		else if ( proxy instanceof PersistentCollection ) {
			( ( PersistentCollection ) proxy ).forceInitialization();
		}
	
public static booleanisInitialized(java.lang.Object proxy)
Check if the proxy or persistent collection is initialized.

param
proxy a persistable object, proxy, persistent collection or null
return
true if the argument is already initialized, or is not a proxy or collection

		if ( proxy instanceof HibernateProxy ) {
			return !( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().isUninitialized();
		}
		else if ( proxy instanceof PersistentCollection ) {
			return ( ( PersistentCollection ) proxy ).wasInitialized();
		}
		else {
			return true;
		}
	
public static booleanisPropertyInitialized(java.lang.Object proxy, java.lang.String propertyName)
Check if the property is initialized. If the named property does not exist or is not persistent, this method always returns true.

param
proxy The potential proxy
param
propertyName the name of a persistent attribute of the object
return
true if the named property of the object is not listed as uninitialized
return
false if the object is an uninitialized proxy, or the named property is uninitialized

		
		Object entity;
		if ( proxy instanceof HibernateProxy ) {
			LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
			if ( li.isUninitialized() ) {
				return false;
			}
			else {
				entity = li.getImplementation();
			}
		}
		else {
			entity = proxy;
		}

		if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
			FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
			return interceptor == null || interceptor.isInitialized( propertyName );
		}
		else {
			return true;
		}
		
	
public static org.hibernate.type.Typeserializable(java.lang.Class serializableClass)
A Hibernate serializable type.

		return new SerializableType( serializableClass );