HIBERNATE - Hibernate O/R Mapping

<class> element

The <Class> element maps the domain object with corresponding entity in the database. hibernate-mapping element allows you to nest several persistent <class> mappings, as shown above. It is however good practice to map only a single persistent class in one mapping file and name it after the persistent superclass, e.g. User.hbm.xml, Group.hbm.xml.


where="arbitrary sql where condition"
check="arbitrary sql check condition"
subselect="SQL expression"



(1) name (optional): The fully qualified Java class name of the persistent class (or interface). If this attribute is missing, it is assumed that the mapping is for a non-POJO entity.
(2) table (optional - defaults to the unqualified class name): The name of its database table.
(3) discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses, used for polymorphic behaviour. Acceptable values include null and not null.
(4) mutable (optional, defaults to true): Specifies that instances of the class are (not) mutable.
(5) schema (optional): Override the schema name specified by the root <hibernate-mapping> element.
(6) catalog (optional): Override the catalog name specified by the root <hibernate-mapping> element.
(7) proxy (optional): Specifies an interface to use for lazy initializing proxies. You may specify the name of the class itself.
(8) dynamic-update (optional, defaults to false): Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed.
(9) dynamic-insert (optional, defaults to false): Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null.
(10) select-before-update (optional, defaults to false): Specifies that Hibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified. In certain cases (actually, only when a transient object has been associated with a new session using update()), this means that Hibernate will perform an extra SQL SELECT to determine if an UPDATE is actually required.
(11) polymorphism (optional, defaults to implicit): Determines whether implicit or explicit query polymorphism is used.
(12) where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving objects of this class
(13) persister (optional): Specifies a custom ClassPersister.
(14) batch-size (optional, defaults to 1) specify a "batch size" for fetching instances of this class by identifier.
(15) optimistic-lock (optional, defaults to version): Determines the optimistic locking strategy.
(16) lazy (optional): Lazy fetching may be completely disabled by setting lazy="false".
(17) entity-name (optional): Hibernate3 allows a class to be mapped multiple times (to different tables, potentially), and allows entity mappings that are represented by Maps or XML at the java level. In these cases, you should provide an explicit arbitrary name for the entity. See Section 4.4, “Dynamic models” for more information.
(18) catalog (optional): The name of a database catalog used for this class and its table.
(19) check (optional): A SQL expression used to generate a multi-row check constraint for automatic schema generation.
(20) rowid (optional): Hibernate can use so called ROWIDs on databases which support. E.g. on Oracle, Hibernate can use the rowid extra column for fast updates if you set this option to rowid. A ROWID is an implementation detail and represents the physical location of a stored tuple.
(21) subselect (optional): Maps an immutable and read-only entity to a database subselect. Useful if you want to have a view instead of a base table, but don't. See below for more information.
(22) abstract (optional): Used to mark abstract superclasses in <union-subclass> hierarchies.

Hibernate tutorial
Introduction to Hibernate
Overview of Hibernate
Features of Hibernate
Getting Started with Hibernate
Hibernate O/R Mapping

Mapping declaration

Mapping Document
<hibernate-mapping> element
<class> element
<id> element
<generator> element
<property> element
<many-to-one> element
<one-to-one> element
Hibernate Mapping In Depth
Hibernate Query Language
Hibernate Complete Example

Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions