Package org.hibernate
This package defines the central Hibernate APIs, beginning with
SessionFactory
, which represents an instance of
Hibernate at runtime and is the source of new instances of
Session
and StatelessSession
,
the most important APIs exposing persistence-related operations for
entities. The interface SharedSessionContract
declares operations that are common to both stateful and stateless sessions.
Playing important supporting roles here, we also have
Transaction
, Filter
,
and Cache
.
APIs related to querying are now defined under the namespace
org.hibernate.query
.
-
Interface Summary Interface Description Cache An API for directly querying and managing the second-level cache.CustomEntityDirtinessStrategy During a flush cycle, Hibernate needs to determine which of the entities associated with aSession
are dirty, meaning modified.CustomEntityDirtinessStrategy.AttributeChecker Responsible for identifying when attributes are dirty.CustomEntityDirtinessStrategy.AttributeInformation ProvidesCustomEntityDirtinessStrategy.AttributeChecker
with meta information about the attributes being checked.CustomEntityDirtinessStrategy.DirtyCheckContext A callback to drive dirty checking.EntityNameResolver An object capable of determining the entity name for a given entity instance.Filter Allows control over an enabled filter at runtime.IdentifierLoadAccess<T> Loads an entity by its primary identifier.Interceptor Allows user code to inspect and/or change entity property values before they are written to the database, or after they are read from the database.LobHelper Metamodel Deprecated. PreferJpaMetamodel
MultiIdentifierLoadAccess<T> Loads multiple instances of a given entity type at once, by specifying a list of identifier values.NaturalIdLoadAccess<T> Loads an entity by its natural identifier, which may be a composite value comprising more than one attribute of the entity.NaturalIdMultiLoadAccess<T> Loads multiple instances of a given entity type at once, by specifying a list of natural id values.ScrollableResults<R> A result iterator that allows moving around within the results by arbitrary increments.Session The main runtime interface between a Java application and Hibernate.Session.LockRequest Deprecated. simply construct aLockOptions
and pass it toSession.lock(Object, LockOptions)
.SessionBuilder Allows creation of a newSession
with specific options.SessionEventListener Implemented by custom listeners that respond to low-level events involving interactions between theSession
and the database or second-level cache.SessionFactory ASessionFactory
represents an "instance" of Hibernate: it maintains the runtime metamodel representing persistent entities, their attributes, their associations, and their mappings to relational database tables, along with configuration that affects the runtime behavior of Hibernate, and instances of services that Hibernate needs to perform its duties.SessionFactoryObserver Allows reaction to basicSessionFactory
lifecycle events.SharedSessionBuilder SpecializedSessionBuilder
with access to stuff from another session.SharedSessionContract Declares operations that are common betweenSession
andStatelessSession
.SimpleNaturalIdLoadAccess<T> Loads an entity by its natural identifier.StatelessSession A command-oriented API often used for performing bulk operations against the database.StatelessSessionBuilder Allows creation of a newStatelessSession
with specific options.Transaction Represents a resource-local transaction, where resource-local is interpreted by Hibernate to mean any transaction under the control of Hibernate. -
Class Summary Class Description BaseSessionEventListener A no-op implementation of SessionEventListener.EmptyInterceptor Deprecated. implementInterceptor
directlyHibernate Various utility functions for working with proxies and lazy collection references.Hibernate.CollectionInterface<C> Operations for obtaining references to persistent collections of a certain type.Length Defines a list of useful constant values that may be used to specify long column lengths in the JPAColumn
annotation.LockOptions Contains a set of options describing how a row of a database table mapped by an entity should be locked.Version Information about the version of Hibernate. -
Enum Summary Enum Description CacheMode Controls how the session interacts with the second-level cache or query cache.ConnectionAcquisitionMode Indicates the manner in which JDBC connections are acquired.ConnectionReleaseMode Enumerates various policies for releasing JDBC connections.DuplicateMappingException.Type Enumeration of the types of things that can be duplicated.FetchMode Represents an association fetching strategy.FlushMode Represents a flushing strategy.LockMode Instances represent a lock mode for a row of a relational database table.ReplicationMode Deprecated. sinceSession.replicate(Object, ReplicationMode)
is deprecatedScrollMode Specifies the type of JDBC scrollable result set to use underneath aScrollableResults
.TimeZoneStorageStrategy Enumerates the possible storage strategies for offset or zoned datetimes. -
Exception Summary Exception Description AnnotationException An exception that occurs while reading mapping annotations.AssertionFailure Indicates failure of an assertion: a possible bug in Hibernate.CallbackException Intended to be thrown fromLifecycle
andInterceptor
callbacks.DuplicateMappingException Raised whenever a duplicate for a certain type occurs, such as a duplicate class, table, or property name.EntityFilterException FetchNotFoundException Exception forNotFoundAction.EXCEPTION
.HibernateError Marks a group of exceptions that generally indicate an internal Hibernate error or bug.HibernateException The base type for exceptions thrown by Hibernate.InstantiationException Thrown if Hibernate can't instantiate a class at runtime.InvalidMappingException Thrown when a mapping is found to be invalid.JDBCException Wraps aSQLException
arising from the JDBC driver.LazyInitializationException Indicates an attempt to access unfetched data outside the context of an open statefulSession
.MappingException An exception that occurs while reading mapping sources, either XML or annotations, usually as a result of something screwy in the O/R mappings.NonUniqueObjectException This exception is thrown when an operation would break session-scoped identity.NonUniqueResultException Thrown when the application callsQuery.getSingleResult()
orQuery.uniqueResult()
and the query returns more than one row from the database.ObjectDeletedException Thrown when the user tries to do something illegal with a deleted object.ObjectNotFoundException Thrown whenEntityManager.find(Class, Object)
fails to select a row with the given primary key (identifier value).PersistentObjectException Thrown when the user passes a persistent instance to aSession
method that expects a transient instance.PessimisticLockException Thrown when a pessimistic locking conflict occurs.PropertyAccessException A problem occurred accessing a property of an instance of a persistent class by reflection, or via enhanced entities.PropertyNotFoundException Indicates that an expected getter or setter method could not be found on a class.PropertySetterAccessException PropertyValueException Thrown when the (illegal) value of a property can not be persisted.QueryException A problem occurred translating a Hibernate query to SQL due to illegal query syntax, an operation which is not well-typed, an unresolvable reference to an entity or attribute, an unknown named query, or any similar problem.QueryParameterException Indicates a problem with the runtime arguments bound to query parameters.QueryTimeoutException Thrown when a database query timeout occurs.ResourceClosedException Indicates an attempt was made to use a closed resource, such as a closedSession
orSessionFactory
.SessionException Thrown when the user calls a method of aSession
that is in an inappropriate state for the given call (for example, the session is closed or disconnected).StaleObjectStateException A specializedStaleStateException
that carries information about the particular entity instance that was the source of the failure.StaleStateException Thrown when a version number or timestamp check failed, indicating that theSession
contained stale data (when using long transactions with versioning).TransactionException Indicates that a transaction could not be begun, committed or rolled back.TransactionManagementException Thrown when user code causes the end of a transaction that is being managed by theSessionFactory
.TransientObjectException Thrown when the user passes a transient instance to aSession
method that expects a persistent instance.TransientPropertyValueException Thrown when a property cannot be persisted because it is an association with a transient unsaved entity instance.TypeMismatchException Used when a user provided type does not match the expected one.UnknownEntityTypeException Indicates an attempt was made to refer to an unknown entity name or class.UnknownFilterException Indicates a request against an unknown filter name.UnknownProfileException Indicates a request against an unknown fetch profile name.UnresolvableObjectException Thrown when Hibernate could not resolve an object by id, especially when loading an association.UnsupportedLockAttemptException This exception is thrown when an invalidLockMode
is selected for an entity.WrongClassException Thrown when loading an entity (by identifier) results in a value that cannot be treated as the subclass type requested by the caller. -
Annotation Types Summary Annotation Type Description Incubating Marks the annotated Java element as incubating, potentially recursively.Internal Marks the annotated Java element as forming part of the internal implementation of Hibernate, meaning that clients should expect absolutely no guarantees with regard to the binary stability from release to release.Remove Indicates that the annotated element is planned for removal as part of a deprecation process.