/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate.metadata;

import java.io.Serializable;
import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.type.Type;

Exposes entity class metadata to the application
Author:Gavin King
See Also:
  • getClassMetadata.getClassMetadata(Class)
/** * Exposes entity class metadata to the application * * @see org.hibernate.SessionFactory#getClassMetadata(Class) * @author Gavin King */
@SuppressWarnings( {"JavaDoc"}) public interface ClassMetadata { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // stuff that is persister-centric and/or EntityInfo-centric ~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The name of the entity
/** * The name of the entity */
public String getEntityName();
Get the name of the identifier property (or return null)
/** * Get the name of the identifier property (or return null) */
public String getIdentifierPropertyName();
Get the names of the class' persistent properties
/** * Get the names of the class' persistent properties */
public String[] getPropertyNames();
Get the identifier Hibernate type
/** * Get the identifier Hibernate type */
public Type getIdentifierType();
Get the Hibernate types of the class properties
/** * Get the Hibernate types of the class properties */
public Type[] getPropertyTypes();
Get the type of a particular (named) property
/** * Get the type of a particular (named) property */
public Type getPropertyType(String propertyName) throws HibernateException;
Does this class support dynamic proxies?
/** * Does this class support dynamic proxies? */
public boolean hasProxy();
Are instances of this class mutable?
/** * Are instances of this class mutable? */
public boolean isMutable();
Are instances of this class versioned by a timestamp or version number column?
/** * Are instances of this class versioned by a timestamp or version number column? */
public boolean isVersioned();
Get the index of the version property
/** * Get the index of the version property */
public int getVersionProperty();
Get the nullability of the class' persistent properties
/** * Get the nullability of the class' persistent properties */
public boolean[] getPropertyNullability();
Get the "laziness" of the properties of this class
/** * Get the "laziness" of the properties of this class */
public boolean[] getPropertyLaziness();
Does this class have an identifier property?
/** * Does this class have an identifier property? */
public boolean hasIdentifierProperty();
Does this entity declare a natural id?
/** * Does this entity declare a natural id? */
public boolean hasNaturalIdentifier();
Which properties hold the natural id?
/** * Which properties hold the natural id? */
public int[] getNaturalIdentifierProperties();
Does this entity have mapped subclasses?
/** * Does this entity have mapped subclasses? */
public boolean hasSubclasses();
Does this entity extend a mapped superclass?
/** * Does this entity extend a mapped superclass? */
public boolean isInherited(); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // stuff that is tuplizer-centric, but is passed a session ~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Return the values of the mapped properties of the object
/** * Return the values of the mapped properties of the object */
@SuppressWarnings( {"UnusedDeclaration"}) public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) throws HibernateException; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // stuff that is Tuplizer-centric ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The persistent class, or null
/** * The persistent class, or null */
public Class getMappedClass();
Create a class instance initialized with the given identifier
Params:
  • id – The identifier value to use (may be null to represent no value)
  • session – The session from which the request originated.
Returns:The instantiated entity.
/** * Create a class instance initialized with the given identifier * * @param id The identifier value to use (may be null to represent no value) * @param session The session from which the request originated. * * @return The instantiated entity. */
public Object instantiate(Serializable id, SessionImplementor session);
Get the value of a particular (named) property
/** * Get the value of a particular (named) property */
public Object getPropertyValue(Object object, String propertyName) throws HibernateException;
Extract the property values from the given entity.
Params:
  • entity – The entity from which to extract the property values.
Throws:
Returns:The property values.
/** * Extract the property values from the given entity. * * @param entity The entity from which to extract the property values. * @return The property values. * @throws HibernateException */
public Object[] getPropertyValues(Object entity) throws HibernateException;
Set the value of a particular (named) property
/** * Set the value of a particular (named) property */
public void setPropertyValue(Object object, String propertyName, Object value) throws HibernateException;
Set the given values to the mapped properties of the given object
/** * Set the given values to the mapped properties of the given object */
public void setPropertyValues(Object object, Object[] values) throws HibernateException;
Get the identifier of an instance (throw an exception if no identifier property)
Deprecated:Use getIdentifier(Object, SessionImplementor) instead
/** * Get the identifier of an instance (throw an exception if no identifier property) * * @deprecated Use {@link #getIdentifier(Object,SessionImplementor)} instead */
@SuppressWarnings( {"JavaDoc"}) public Serializable getIdentifier(Object object) throws HibernateException;
Get the identifier of an instance (throw an exception if no identifier property)
Params:
  • entity – The entity for which to get the identifier
  • session – The session from which the request originated
Returns:The identifier
/** * Get the identifier of an instance (throw an exception if no identifier property) * * @param entity The entity for which to get the identifier * @param session The session from which the request originated * * @return The identifier */
public Serializable getIdentifier(Object entity, SessionImplementor session);
Inject the identifier value into the given entity.
Params:
  • entity – The entity to inject with the identifier value.
  • id – The value to be injected as the identifier.
  • session – The session from which is requests originates
/** * Inject the identifier value into the given entity. * * @param entity The entity to inject with the identifier value. * @param id The value to be injected as the identifier. * @param session The session from which is requests originates */
public void setIdentifier(Object entity, Serializable id, SessionImplementor session);
Does the class implement the Lifecycle interface?
/** * Does the class implement the <tt>Lifecycle</tt> interface? */
@SuppressWarnings( {"UnusedDeclaration"}) public boolean implementsLifecycle();
Get the version number (or timestamp) from the object's version property (or return null if not versioned)
/** * Get the version number (or timestamp) from the object's version property * (or return null if not versioned) */
public Object getVersion(Object object) throws HibernateException; }