Print
HibernateTags

@hibernate tags

@hibernate.any-column

Defines a column for the any type mapping

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   The column name
unique-key false Any value   no   The name of a unique constraint
comment false Any value   no   comment for this column
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
index false Any value   no   Name of database index
unique false true, false   no   defines inqueness status in database terms
not-null false true, false   no   Nullability status
precision false Any value   no   Precission.
length false Any value   no   Column length
sql-type false Any value   no   Specify sql type
scale false Any value   no   Scale.

@hibernate.any

An "any" association is a polymorphic association to any table with

the given identifier type. The first listed column is a VARCHAR column

holding the name of the class (for that row). This tag requires at least one

@hibernate.column, and may require use of @hibernate.meta and @hibernate.meta-value tags

Unique true

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
optimistic-lock false true, false   no   Specifies that updates to this property do or do not require acquisition of the optimistic lock.

In other words, define if a version increment should occur if this property is dirty.
lazy false true, false, proxy, no-proxy, extra   no   Lazyness. Lazy fetching may be completely disabled by setting lazy="false"
index false Any value   no   Name of database index
insert false true, false   no   Should the column appear in the SQL INSERT
node false Any value   no   Node definition.
update false true, false   no   Should the column appear in the SQL UPDATE
id-type true Any value   no   The identifier type of mapped entries.
access false Any value   no   The strategy Hibernate should use for accessing the property value.
cascade false Any value   no   Specifies which operations should be cascaded from the parent object to the associated object
meta-type false Any value   no   Specify a custom type that maps database column values to persistent

classes which have identifier properties of the type specified by id-type.

If the meta-type returns instances of java.lang.Class, nothing else is

required. On the other hand, if it is a basic type like string or

character, you must specify the mapping from values to classes.

@hibernate.array

defines array collection. @hibernate.key , @hibernate.index and collection element shall be specified

Unique true

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
element-class false Any value   no   specifies element class ( implied by type )
inverse false true, false   no   if this collection is inverse. Inverse mean that changes on this side of

association will not trigger database operations. in case fo bidirectional

many-to-many association one of the sides shall be declared as inverse to

prtevent strange databse behaviour. ( double inserts )
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
subselect false Any value   no   aps 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.
outer-join false true, false, auto   no   Enable outer-join fetching
schema false Any value   no   Defines database schema
table false Any value   no   Defines database table
where false Any value   no   defines where clause to be used.
fetch false join, select, subselect   no   Chooses between outer-join fetching or sequential select fetching.
node false Any value   no   Node definition.
mutable false true, false   no    
batch-size false Any value   no   Specifies batch size
access false Any value   no   The strategy Hibernate should use for accessing the property value.
cascade false Any value   no   Specifies which operations should be cascaded from the parent object to the associated object
catalog false Any value   no   The name of a database catalog.
collection-type false Any value   no   Collection type.
optimistic-lock false true, false   no   Collection: species that changes to the state of the collection results in increment of the owning entity's

version.(For one to many associations, it is often reasonable to disable this setting.)
embed-xml false true, false   no   If embed-xml="true", the default, the XML tree for the associated entity (or collection of value type)

will be embedded directly in the XML tree for the entity that owns the association. Otherwise, if

embed-xml="false", then only the referenced identifier value will appear in the XML for single point

associations and collections will simply not appear at all.
persister false Any value   no   Specifies a custom ClassPersister.

@hibernate.bag

Defines a collection with a bag semantic. It's like list, but does not need explicit

indexing column. This tag requires bag element definition.

Unique true

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
lazy false true, false, proxy, no-proxy, extra   no   Lazyness. Lazy fetching may be completely disabled by setting lazy="false"
order-by false Any value   no   Specify hibernate ordering. Optional, JDK1.4 only. Specify a table column (or columns) that define the

iteration order of the Map, Set or bag, together with an optional asc or desc.
inverse false true, false   no   if this collection is inverse. Inverse mean that changes on this side of

association will not trigger database operations. in case fo bidirectional

many-to-many association one of the sides shall be declared as inverse to

prtevent strange databse behaviour. ( double inserts )
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
subselect false Any value   no   aps 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.
outer-join false true, false, auto   no   Enable outer-join fetching
schema false Any value   no   Defines database schema
table false Any value   no   Defines database table
where false Any value   no   defines where clause to be used.
fetch false join, select, subselect   no   Chooses between outer-join fetching or sequential select fetching.
node false Any value   no   Node definition.
mutable false true, false   no    
batch-size false Any value   no   Specifies batch size
access false Any value   no   The strategy Hibernate should use for accessing the property value.
cascade false Any value   no   Specifies which operations should be cascaded from the parent object to the associated object
catalog false Any value   no   The name of a database catalog.
collection-type false Any value   no   Collection type.
optimistic-lock false true, false   no   Collection: species that changes to the state of the collection results in increment of the owning entity's

version.(For one to many associations, it is often reasonable to disable this setting.)
embed-xml false true, false   no   If embed-xml="true", the default, the XML tree for the associated entity (or collection of value type)

will be embedded directly in the XML tree for the entity that owns the association. Otherwise, if

embed-xml="false", then only the referenced identifier value will appear in the XML for single point

associations and collections will simply not appear at all.
persister false Any value   no   Specifies a custom ClassPersister.

@hibernate.cache

Enables caching

Unique false

Allowed locations

class method constructor field
true true false true
Parameter Required Allowed values Default value Array Token separator Description
region false Any value   no   Name of a cache region.
usage true transactional, read-write, nonstrict-read-write, read-only   no   Defines the cache semantics

@hibernate.class

Declare a persistent class

Unique true

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
optimistic-lock false none, dirty, version, all   no    
polymorphism false explicit, implicit   no   Enable "explicit" polymorphism
lazy false true, false, proxy, no-proxy, extra   no   Lazyness. Lazy fetching may be completely disabled by setting lazy="false"
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
select-before-update false true, false   no   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.
dynamic-update false true, false   no   Whether dynymic update is allowed
subselect false Any value   no   aps 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.
schema false Any value   no   Defines database schema
entity-name false Any value   no   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.
table false Any value   no   Defines database table
dynamic-insert false true, false   no   Whether dynamic insert is allowed
where false Any value   no   defines where clause to be used.
name false Any value   no   Specifies the name.
proxy false Any value   no   Specifies an interface to use for CGLIB proxies
rowid false Any value   no   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.
node false Any value   no   Node definition.
mutable false true, false   no    
batch-size false Any value   no   Specifies batch size
catalog false Any value   no   The name of a database catalog.
persister false Any value   no   Specifies a custom ClassPersister.
abstract false true, false   no   Used to mark abstract superclasses in <union-subclass> hierarchies.
discriminator-value false Any value   no   Specifies discriminator value. A value that distiguishes individual subclasses, used for

polymorphic behaviour. Acceptable values include null and not null.

@hibernate.collection-id

<collection-id> definition for <idbag>.

Unique false

Allowed locations

class method constructor field
true true true true
Parameter Required Allowed values Default value Array Token separator Description
column true Any value   no   Specifies database column. If not specified hibernate will guess based on property

name.
generator-class true Any value   no   Name of a generator class. All generators implement the interface <code>org.hibernate.id.IdentifierGenerator</code>.

There are names for the built-in generators:

<ul>

<li>increment</li>

<li>identity</li>

<li>sequence</li>

<li>hilo</li>

<li>seqhilo</li>

<li>seqhilo</li>

<li>uuid</li>

<li>guid</li>

<li>native</li>

<li>assigned</li>

<li>select</li>

<li>foreign</li>

</ul>
type true Any value   no   Specify hibernate type.
length false Any value   no   Column length

@hibernate.column

Customize column mapping.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   The column name
unique-key false Any value   no   The name of a unique constraint
comment false Any value   no   comment for this column
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
index false Any value   no   Name of database index
unique false true, false   no   defines inqueness status in database terms
not-null false true, false   no   Nullability status
precision false Any value   no   Precission.
length false Any value   no   Column length
sql-type false Any value   no   Specify sql type
scale false Any value   no   Scale.

@hibernate.comment

represents comment which can be placed in various places into mapping this

tag does not define any parameters and contens will be used verbatim. this

tag replaces comment parameters found in various tags

Unique true

Allowed locations

class method constructor field
true true true true

@hibernate.component

declare property to be hibernate component. A component is a user-defined class, persisted

along with its containing entity to the table of the entity class. JavaBeans

style properties of the component are mapped to columns of the table of the

containing entity.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
optimistic-lock false true, false   no   Specifies that updates to this component do or do not require acquisition of the optimistic lock.

In other words, determines if a version increment should occur when this property is dirty.
prefix false Any value   no   When multiple Java fields are of the same component datatype, use this to specify a descriminating

column-name-prefix. Properties that are included which have a @hibernate.property column="xxx"

attribute or @hibernate.column name="xxx" on the property will be prefixed.
lazy false true, false, proxy, no-proxy, extra   no   Lazyness. Lazy fetching may be completely disabled by setting lazy="false"
properties-name false Any value   no   Define what <properties> tag this property belongs to.

If attribute is absent it means that property does not belong to any propertis set.
insert false true, false   no   Should the column appear in the SQL INSERT
node false Any value   no   Node definition.
unique false true, false   no   defines inqueness status in database terms
join-name false Any value   no   Define what <join> tag this property belongs to.

If attribute is absent it means that property does not belong to any <join> tag.
update false true, false   no   Should the column appear in the SQL UPDATE
class false Any value   no   Specifies the class name.
access false Any value   no   The strategy Hibernate should use for accessing the property value.

@hibernate.composite-element

Declares a composite collection element

Unique true

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   Specifies the class name of composite element.
node false Any value   no   Node definition.

@hibernate.composite-id

Declares a composite-id. For a table with a composite key, you may map multiple properties of the class

as identifier properties. The <composite-id> element accepts <key-property> property mappings

and <key-many-to-one> mappings as child elements.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
unsaved-value false Any value   no   A value that distinguishes transient instances with existing persistent state from new transient instances
class false Any value   no   Specifies the class name.
access false Any value   no   The strategy Hibernate should use for accessing the property value.

@hibernate.composite-index

Composite index of a map ie. a map keyed on components.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   Component class name.

@hibernate.composite-key

Declares a composite collection element. Strictly specking this tag is not necessary in hibernate3 as it

will make a guess and produce some obscure column name for you. Collection key defined which column in

resulting table is to be used as reference to id of owner entity.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   The name of the element class

@hibernate.composite-map-key

Composite index of a map ie. a map keyed on components.

<composite-map-key> is preferred to <composite-index>

Unique false

Allowed locations

class method constructor field
true true true true
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   Component class name.

@hibernate.discriminator-column

Declares column as child of key element

Unique false

Allowed locations

class method constructor field
true true true true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   The column name
unique-key false Any value   no   The name of a unique constraint
comment false Any value   no   comment for this column
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
index false Any value   no   Name of database index
unique false true, false   no   defines inqueness status in database terms
not-null false true, false   no   Nullability status
precision false Any value   no   Precission.
length false Any value   no   Column length
sql-type false Any value   no   Specify sql type
scale false Any value   no   Scale.

@hibernate.discriminator

Defines a discriminator. Polymorphic data requires a column holding a class discriminator value. This

value is not directly exposed to the application.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
column false Any value   no   The name of the mapped database table column
force false true, false   no   do not know what it means.
formula false Any value   no   An arbitrary SQL expression that is executed when a type has to be evaluated. Allows content-based

discrimination.
insert false true, false   no   Should the column appear in the SQL INSERT
not-null false true, false   no   Nullability status
type false Any value   no   Specify hibernate type
length false Any value   no   Column length

@hibernate.element

Declares the element type of a collection of basic ( primitive ) type.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
type true Any value   no   The Hibernate type
formula false Any value   no   An arbitrary SQL expression that is executed when a type has to be evaluated. Allows content-based

discrimination.
node false Any value   no   Node definition.
unique false true, false   no   defines inqueness status in database terms
not-null false true, false   no   Nullability status
length false Any value   no   Column length
column false Any value   no   Specifies database column. If not specified hibernate will guess based on property name

@hibernate.filter-def

Top-level filter definition.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   Filter name
condition false Any value   no   Definition of a condition.

@hibernate.filter-param

Filter parameter definition.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   Filter parameter name.
type true Any value   no   Type of a filter parameter.
filterdef-name false Any value   no   Name of the filter-def which this parameter is applied

@hibernate.filter

Definition of a filter attached to a class or collection.

Unique false

Allowed locations

class method constructor field
true true false true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   Filter name.
condition false Any value   no   Definition of a condition.

@hibernate.formula

Formula an arbitrary SQL expression that is executed when a type has to be evaluated.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
value false Any value   no   Value of attribute

@hibernate.generator-param

If any parameters are required to configure or initialize the generator instance, they are

passed using the <param> element.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   Parameter name.
value false Any value   no   Parameter value.

@hibernate.id

Mapped classes must declare the primary key column of the database table. Most classes will also have a

JavaBeans-style property holding the unique identifier of an instance. The <id> element defines the

mapping from that property to the primary key column.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
generator-class true Any value   no   The key generator class. Hibernate recognizes standart generator

classes: "uuid.hex", "uuid.string", "increment", "assigned", "native", "identity", "sequence", "hilo", "seqhilo",

"foreign" ( See hibernate documentation for meaning of those ) as well as fully qualified name of custom generator

class
name false Any value   no   Specifies the name.
unsaved-value false Any value   no   A value that distinguishes transient instances with existing persistent state from new transient instances
node false Any value   no   Node definition.
type false Any value   no   Specify hibernate type
length false Any value   no   Column length
access false Any value   no   The strategy Hibernate should use for accessing the property value.
column false Any value   no   Specifies database column. If not specified hibernate will guess based on property name

@hibernate.idbag

Defines a idbag.

Unique false

Allowed locations

class method constructor field
true true true true
Parameter Required Allowed values Default value Array Token separator Description
lazy false true, false, proxy, no-proxy, extra   no   Lazyness. Lazy fetching may be completely disabled by setting lazy="false"
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
subselect false Any value   no   aps 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.
outer-join false true, false, auto   no   Enable outer-join fetching
schema false Any value   no   Defines database schema
table false Any value   no   Defines database table
where false Any value   no   defines where clause to be used.
fetch false join, select, subselect   no   Chooses between outer-join fetching or sequential select fetching.
node false Any value   no   Node definition.
mutable false true, false   no    
batch-size false Any value   no   Specifies batch size
access false Any value   no   The strategy Hibernate should use for accessing the property value.
cascade false Any value   no   Specifies which operations should be cascaded from the parent object to the associated object
catalog false Any value   no   The name of a database catalog.
collection-type false Any value   no   Collection type.
optimistic-lock false true, false   no   Collection: species that changes to the state of the collection results in increment of the owning entity's

version.(For one to many associations, it is often reasonable to disable this setting.)
embed-xml false true, false   no   If embed-xml="true", the default, the XML tree for the associated entity (or collection of value type)

will be embedded directly in the XML tree for the entity that owns the association. Otherwise, if

embed-xml="false", then only the referenced identifier value will appear in the XML for single point

associations and collections will simply not appear at all.
persister false Any value   no   Specifies a custom ClassPersister.
order-by false Any value   no   Specify hibernate ordering. Optional, JDK1.4 only. Specify a table column (or columns) that define the

iteration order of the Map, Set or bag, together with an optional asc or desc.

@hibernate.import

Suppose your application has two persistent classes with the same name, and you don't want to specify

the fully qualified (package) name in Hibernate queries. Classes may be "imported" explicitly, rather

than relying upon auto-import="true". You may even import classes and interfaces that are not explicitly

mapped.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   The fully qualified class name of of any Java class.
rename false Any value   no   A name that may be used in the query language.

@hibernate.index-column

declares column as child of index element

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
name true Any value   no   The column name
unique-key false Any value   no   The name of a unique constraint
comment false Any value   no   comment for this column
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
index false Any value   no   Name of database index
unique false true, false   no   defines inqueness status in database terms
not-null false true, false   no   Nullability status
precision false Any value   no   Precission.
length false Any value   no   Column length
sql-type false Any value   no   Specify sql type
scale false Any value   no   Scale.

@hibernate.index-many-to-any

Many to many association mapped to the key of a map ie. a map keyed on entities.

Unique false

Allowed locations

class method constructor field
true true true true
Parameter Required Allowed values Default value Array Token separator Description
id-type true Any value   no   The identifier type of mapped entries.
meta-type false Any value   no   Specify a custom type that maps database column values to persistent

classes which have identifier properties of the type specified by id-type.

If the meta-type returns instances of java.lang.Class, nothing else is

required. On the other hand, if it is a basic type like string or

character, you must specify the mapping from values to classes.

@hibernate.index-many-to-many

Declares many-to-many collection index. Will be used as map key for ternary associations. Shall be an entity

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
class true Any value   no   Entity to be used as key in the ternary association maps
foreign-key false Any value   no   Declaration of column name for foreign key constraint
entity-name false Any value   no   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.
column false Any value   no   Specifies database column. If not specified hibernate will guess based on property name

@hibernate.index

Declares a collection index. This will be used as index for the arrays, sotring field for the lists or keys in the map

The <index> element is semi-deprecated in Hibernate3, <list-index> and <map-key> are preferred.

Unique false

Allowed locations

class method constructor field
false true false true
Parameter Required Allowed values Default value Array Token separator Description
node false Any value   no   Node definition.
type false Any value   no   Specify hibernate type
length false Any value   no   Column length
column false Any value   no   Specifies database column. If not specified hibernate will guess based on property name

@hibernate.jcs-cache

Enables caching

Unique false

Allowed locations

class method constructor field
true true false true
Parameter Required Allowed values Default value Array Token separator Description
usage true read-write, nonstrict-read-write, read-only   no   Defines the cache semantics

@hibernate.join-key

Using the <join-key> element, it is possible to map properties of one class to several tables.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
column false Any value   no   If enabled, Hibernate will insert a row only if the properties defined by this join are non-null

and will always use an outer join to retrieve the properties.

@hibernate.join

Using the <join> element, it is possible to map properties of one class to several tables.

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
optional false true, false   no   If enabled, Hibernate will insert a row only if the properties defined by this join are non-null

and will always use an outer join to retrieve the properties.
table true Any value   no   The name of the joined table.
name true Any value   no   The name of the join
fetch false join, select, subselect   no   Chooses between outer-join fetching or sequential select fetching.
subselect false Any value   no   aps 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.
schema false Any value   no   Defines database schema
inverse false true, false   no   Should the column appear in the SQL UPDATE
catalog false Any value   no   The name of a database catalog.

@hibernate.joined-subclass-key

Declares a joined-subclass key

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
column false Any value   no   Specifies database column. If not specified hibernate will guess based on property name

@hibernate.joined-subclass

Declare the current class as joined subclass

Unique false

Allowed locations

class method constructor field
true false false false
Parameter Required Allowed values Default value Array Token separator Description
check false Any value   no   A SQL expression used to generate a multi-row check constraint for automatic schema generation.
lazy false true, false, proxy, no-proxy, extra   no