Defining Hibernate Class Mapping Options

Classes can be mapped to tables or views. Since views have many constraints and limited functionality (for example they do not have primary keys and reference keys), some views cannot be updated, and the mappings may not work properly in some cases.

There are some conditions that need to be met in order to generate mapping for a specific class:

  • The Java source can be generated. This may not be possible if, for example, the visibility of the class is private.

  • The class is persistent.

  • The generation mode is not set to Generate ADT (abstract data type).

  • If the class is an inner class, it must be static, and have public visibility. Hibernate should then be able to create instances of the class.

Hibernate-specific class mapping options can be defined in the Hibernate tab of the class property sheet:



Option

Description

Dynamic insert

Specifies that INSERT SQL should be generated at runtime and will contain only the columns whose values are not null.

Hibernate Tag: dynamic-insert

Dynamic update

Specifies that UPDATE SQL should be generated at runtime and will contain only the columns whose values have changed.

Hibernate Tag: dynamic-update

Select before update

Specifies that Hibernate should never perform a SQL UPDATE unless it is certain that an object is actually modified.

Hibernate Tag: select-before-update

Default cascade type

Specifies the default cascade style.

Hibernate Tag: default-cascade

Default access type

Specifies the default access type (field or property)

Hibernate Tag: default-access

Proxy name

Specifies an interface to use for lazy initializing proxies.

Hibernate Tag: proxy

Batch size

Specifies a "batch size" for fetching instances of this class by identifier.

Hibernate Tag: batch-size

Check

Specifies a SQL expression used to generate a multi-row check constraint for automatic schema generation.

Hibernate Tag: check

Polymorphism

Specifies whether implicit or explicit query polymorphism is used.

Hibernate Tag: polymorphism

Schema name

Specifies the name of the database schema.

Hibernate Tag: schema

Catalog name

Specifies the name of the database catalog.

Hibernate Tag: catalog

Row id

Specifies that Hibernate can use the ROWID column on databases which support it (for example, Oracle).

Hibernate Tag: rowed

Persister class name

Specifies a custom persistence class.

Hibernate Tag: persister

Lazy

Specifies that the class should be lazy fetching.

Hibernate Tag: lazy

Mutable

Specifies that instances of the class are mutable.

Hibernate Tag: mutable

Abstract class

Specifies that the class is abstract.

Hibernate Tag: abstract

Auto import

Specifies that an unqualified class name can be used in a query

Hibernate Tag: Auto-import

Discriminator column

Specifies the discriminator column or formula for polymorphic behavior in a one table per hierarchy mapping strategy.

Hibernate Tag: discriminator

Discriminator value

Specifies a value that distinguishes individual subclasses, which are used for polymorphic behavior.

Hibernate Tag: discriminator-value

Discriminator type

Specifies the discriminator type.

Hibernate Tag: type

Force usage of discriminator

Forces Hibernate to specify allowed discriminator values even when retrieving all instances of the root class.

Hibernate Tag: force

Do not use discriminator in insert

Forces Hibernate to not include the column in SQL INSERTs

Hibernate Tag: insert

Optimistic lock type

Specifies an optimistic locking strategy.

Hibernate Tag: optimistic-lock

Optimistic lock column name

Specifies the column used for optimistic locking. A field is also generated if this option is set.

Hibernate Tag: version/ timestamp

Optimistic lock unsaved value

Specifies whether an unsaved value is null or undefined.

Hibernate Tag: unsaved-value