Package org.hibernate.tool.schema
Enum Class Action
- All Implemented Interfaces:
Serializable
,Comparable<Action>
,Constable
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.
- An action to be executed against the database may be specified using the configuration property "jakarta.persistence.schema-generation.database.action" or using the property "hibernate.hbm2ddl.auto".
- An action to be written to a script may be specified using the configuration property "jakarta.persistence.schema-generation.scripts.action".
- API Note:
- There is an ambiguity surrounding the value
"create"
here. The old-school Hibernate configuration interprets this as the actionCREATE
, which drops the schema before recreating it. The JPA standard interprets it to mean the actionCREATE_ONLY
which does not first drop the schema.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDrop and then recreate the schema.Drop the schema and then recreate it onSessionFactory
startup.Create the schema.Drop the schema.No action.Truncate the tables in the schema.Update (alter) the database schema.Validate the database schema. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionThe string configuration value identifying this action in old-school Hibernate configuration via "hibernate.hbm2ddl.auto".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".static Action
interpretHbm2ddlSetting
(Object value) Interpret the value of the old-school Hibernate configuration property "hibernate.hbm2ddl.auto" as an instance ofAction
.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 ofAction
.toString()
static Action
Returns the enum constant of this class with the specified name.static Action[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No action.- API Note:
- Valid in JPA; identical to the HBM2DDL action of the same name.
-
CREATE_ONLY
Create the schema.- See Also:
- API Note:
- This is an action introduced by JPA; the legacy HBM2DDL tool had
no such action. Its action named
"create"
was equivalent toCREATE
.
-
DROP
Drop the schema.- See Also:
- API Note:
- Valid in JPA; identical to the HBM2DDL action of the same name.
-
CREATE
Drop and then recreate the schema.- See Also:
- API Note:
- This action is called
"drop-and-create"
by JPA, but simply"create"
by the legacy HBM2DDL tool.
-
CREATE_DROP
Drop the schema and then recreate it onSessionFactory
startup. Additionally, drop the schema onSessionFactory
shutdown.While this is a valid option for auto schema tooling, it's not a valid action for the
SchemaManagementTool
; instead the caller ofSchemaManagementTool
must split this into two separate requests to:- drop and create the schema, and then
- later, drop the schema again.
- See Also:
- API Note:
- This action is not defined by JPA.
-
VALIDATE
Validate the database schema.- See Also:
- API Note:
- This action is not defined by JPA.
-
UPDATE
Update (alter) the database schema.- See Also:
- API Note:
- This action is not defined by JPA.
-
TRUNCATE
Truncate the tables in the schema.- Since:
- 6.2
- See Also:
- API Note:
- This action is not defined by JPA.
-
-
Field Details
-
ACTION_NONE
- See Also:
-
ACTION_DROP
- See Also:
-
ACTION_CREATE_ONLY
- See Also:
-
ACTION_CREATE
- See Also:
-
ACTION_CREATE_THEN_DROP
- See Also:
-
ACTION_VALIDATE
- See Also:
-
ACTION_UPDATE
- See Also:
-
SPEC_ACTION_NONE
- See Also:
-
SPEC_ACTION_DROP
- See Also:
-
SPEC_ACTION_CREATE
- See Also:
-
SPEC_ACTION_DROP_AND_CREATE
- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
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". -
getExternalHbm2ddlName
The string configuration value identifying this action in old-school Hibernate configuration via "hibernate.hbm2ddl.auto". -
toString
-
interpretJpaSetting
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 ofAction
.- Parameters:
value
- The encountered config value- Returns:
- The matching enum value. An empty value will return
NONE
. - Throws:
IllegalArgumentException
- If the incoming value is unrecognized
-
interpretHbm2ddlSetting
Interpret the value of the old-school Hibernate configuration property "hibernate.hbm2ddl.auto" as an instance ofAction
.- Parameters:
value
- The encountered config value- Returns:
- The matching enum value. An empty value will return
NONE
. - Throws:
IllegalArgumentException
- If the incoming value is unrecognized
-