Top Description Fields Constructors Methods
org.hibernate.tool.schema

public final Enum Action

extends Enum<Action>
Class Inheritance
Static Imports
org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO

Enumerates the actions that may be performed by the schema management tooling. Covers the actions defined by JPA, those defined by Hibernate's legacy HBM2DDL tool, and several useful actions supported by Hibernate which are not covered by the JPA specification.

API Note

There is an ambiguity surrounding the value "create" here. The old-school Hibernate configuration interprets this as the action CREATE, which drops the schema before recreating it. The JPA standard interprets it to mean the action CREATE_ONLY which does not first drop the schema.

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final Action
CREATE

Drop and then recreate the schema.

public static final Action
CREATE_DROP

Drop the schema and then recreate it on SessionFactory startup.

public static final Action
CREATE_ONLY

Create the schema.

public static final Action
DROP

Drop the schema.

public static final Action
NONE

No action.

public static final String
public static final String
public static final String
public static final String
public static final Action
TRUNCATE

Truncate the tables in the schema.

public static final Action
UPDATE

Update (alter) the database schema.

public static final Action
VALIDATE

Validate the database schema.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
getExternalHbm2ddlName()

The string configuration value identifying this action in old-school Hibernate configuration via hibernate.hbm2ddl.auto.

public String
getExternalJpaName()

The string configuration value identifying this action in JPA-standard configuration via jakarta.persistence.schema-generation.database.action or jakarta.persistence.schema-generation.scripts.action.

public static Action

Returns:

The matching enum value. An empty value will return NONE.
interpretHbm2ddlSetting
(Object
The encountered config value
value
)

Interpret the value of the old-school Hibernate configuration property hibernate.hbm2ddl.auto as an instance of Action.

public static Action

Returns:

The matching enum value. An empty value will return NONE.
interpretJpaSetting
(Object
The encountered config value
value
)

Interpret the value of the JPA-standard configuration property jakarta.persistence.schema-generation.database.action or jakarta.persistence.schema-generation.scripts.action as an instance of Action.

public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static Action
public static Action[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

ACTION_CREATEback to summary
public static final String ACTION_CREATE
See Also
CREATE
ACTION_CREATE_ONLYback to summary
public static final String ACTION_CREATE_ONLY
See Also
CREATE_ONLY
ACTION_CREATE_THEN_DROPback to summary
public static final String ACTION_CREATE_THEN_DROP
See Also
CREATE_DROP
ACTION_DROPback to summary
public static final String ACTION_DROP
See Also
DROP
ACTION_NONEback to summary
public static final String ACTION_NONE
See Also
NONE
ACTION_UPDATEback to summary
public static final String ACTION_UPDATE
See Also
UPDATE
ACTION_VALIDATEback to summary
public static final String ACTION_VALIDATE
See Also
VALIDATE
CREATEback to summary
public static final Action CREATE

Drop and then recreate the schema.

API Note

This action is called "drop-and-create" by JPA, but simply "create" by the legacy HBM2DDL tool.

See Also
org.hibernate.tool.schema.spi.SchemaDropper, org.hibernate.tool.schema.spi.SchemaCreator
CREATE_DROPback to summary
public static final Action CREATE_DROP

Drop the schema and then recreate it on SessionFactory startup. Additionally, drop the schema on SessionFactory shutdown.

While this is a valid option for auto schema tooling, it's not a valid action for the SchemaManagementTool; instead the caller of SchemaManagementTool must split this into two separate requests to:

  1. drop and create the schema, and then
  2. later, drop the schema again.

API Note

This action is not defined by JPA.

See Also
org.hibernate.tool.schema.spi.SchemaDropper, org.hibernate.tool.schema.spi.SchemaCreator
CREATE_ONLYback to summary
public static final Action CREATE_ONLY

Create the schema.

API Note

This is an action introduced by JPA; the legacy HBM2DDL tool had no such action. Its action named "create" was equivalent to CREATE.

See Also
org.hibernate.tool.schema.spi.SchemaCreator
DROPback to summary
public static final Action DROP

Drop the schema.

API Note

Valid in JPA; identical to the HBM2DDL action of the same name.

See Also
org.hibernate.tool.schema.spi.SchemaDropper
NONEback to summary
public static final Action NONE

No action.

API Note

Valid in JPA; identical to the HBM2DDL action of the same name.

SPEC_ACTION_CREATEback to summary
public static final String SPEC_ACTION_CREATE
See Also
CREATE_ONLY
SPEC_ACTION_DROPback to summary
public static final String SPEC_ACTION_DROP
See Also
DROP
SPEC_ACTION_DROP_AND_CREATEback to summary
public static final String SPEC_ACTION_DROP_AND_CREATE
See Also
CREATE
SPEC_ACTION_NONEback to summary
public static final String SPEC_ACTION_NONE
See Also
NONE
TRUNCATEback to summary
public static final Action TRUNCATE

Truncate the tables in the schema.

API Note

This action is not defined by JPA.

Since
6.2
See Also
org.hibernate.tool.schema.spi.SchemaTruncator
UPDATEback to summary
public static final Action UPDATE

Update (alter) the database schema.

API Note

This action is not defined by JPA.

See Also
org.hibernate.tool.schema.spi.SchemaMigrator
VALIDATEback to summary
public static final Action VALIDATE

Validate the database schema.

API Note

This action is not defined by JPA.

See Also
org.hibernate.tool.schema.spi.SchemaValidator

Constructor Detail

Actionback to summary
private Action()

Method Detail

getExternalHbm2ddlNameback to summary
public String getExternalHbm2ddlName()

The string configuration value identifying this action in old-school Hibernate configuration via hibernate.hbm2ddl.auto.

getExternalJpaNameback to summary
public String getExternalJpaName()

The string configuration value identifying this action in JPA-standard configuration via jakarta.persistence.schema-generation.database.action or jakarta.persistence.schema-generation.scripts.action.

interpretHbm2ddlSettingback to summary
public static Action interpretHbm2ddlSetting(Object value)

Interpret the value of the old-school Hibernate configuration property hibernate.hbm2ddl.auto as an instance of Action.

Parameters
value:Object

The encountered config value

Returns:Action

The matching enum value. An empty value will return NONE.

Exceptions
IllegalArgumentException:
If the incoming value is unrecognized
interpretJpaSettingback to summary
public static Action interpretJpaSetting(Object value)

Interpret the value of the JPA-standard configuration property jakarta.persistence.schema-generation.database.action or jakarta.persistence.schema-generation.scripts.action as an instance of Action.

Parameters
value:Object

The encountered config value

Returns:Action

The matching enum value. An empty value will return NONE.

Exceptions
IllegalArgumentException:
If the incoming value is unrecognized
toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static Action valueOf(String name)
valuesback to summary
public static Action[] values()