Package org.hibernate.tool.schema
Enum Action
- java.lang.Object
-
- java.lang.Enum<Action>
-
- org.hibernate.tool.schema.Action
-
- All Implemented Interfaces:
Serializable
,Comparable<Action>
public enum Action extends Enum<Action>
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.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CREATE
Drop and then recreate the schema.CREATE_DROP
Drop the schema and then recreate it onSessionFactory
startup.CREATE_ONLY
Create the schema.DROP
Drop the schema.NONE
No action.TRUNCATE
Truncate the tables in the schema.UPDATE
Update (alter) the database schema.VALIDATE
Validate the database schema.
-
Field Summary
Fields Modifier and Type Field Description static String
ACTION_CREATE
static String
ACTION_CREATE_ONLY
static String
ACTION_CREATE_THEN_DROP
static String
ACTION_DROP
static String
ACTION_NONE
static String
ACTION_UPDATE
static String
ACTION_VALIDATE
static String
SPEC_ACTION_CREATE
static String
SPEC_ACTION_DROP
static String
SPEC_ACTION_DROP_AND_CREATE
static String
SPEC_ACTION_NONE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getExternalHbm2ddlName()
The string configuration value identifying this action in old-school Hibernate configuration via "hibernate.hbm2ddl.auto".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".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
.String
toString()
static Action
valueOf(String name)
Returns the enum constant of this type with the specified name.static Action[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
public static final Action NONE
No action.- API Note:
- Valid in JPA; identical to the HBM2DDL action of the same name.
-
CREATE_ONLY
public static final Action CREATE_ONLY
Create the schema.- See Also:
SchemaCreator
- 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
public static final Action DROP
Drop the schema.- See Also:
SchemaDropper
- API Note:
- Valid in JPA; identical to the HBM2DDL action of the same name.
-
CREATE
public static final Action CREATE
Drop and then recreate the schema.- See Also:
SchemaDropper
,SchemaCreator
- API Note:
- This action is called
"drop-and-create"
by JPA, but simply"create"
by the legacy HBM2DDL tool.
-
CREATE_DROP
public static final Action 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:
SchemaDropper
,SchemaCreator
- API Note:
- This action is not defined by JPA.
-
VALIDATE
public static final Action VALIDATE
Validate the database schema.- See Also:
SchemaValidator
- API Note:
- This action is not defined by JPA.
-
UPDATE
public static final Action UPDATE
Update (alter) the database schema.- See Also:
SchemaMigrator
- API Note:
- This action is not defined by JPA.
-
TRUNCATE
public static final Action TRUNCATE
Truncate the tables in the schema.- Since:
- 6.2
- See Also:
SchemaTruncator
- API Note:
- This action is not defined by JPA.
-
-
Field Detail
-
ACTION_NONE
public static final String ACTION_NONE
- See Also:
NONE
, Constant Field Values
-
ACTION_DROP
public static final String ACTION_DROP
- See Also:
DROP
, Constant Field Values
-
ACTION_CREATE_ONLY
public static final String ACTION_CREATE_ONLY
- See Also:
CREATE_ONLY
, Constant Field Values
-
ACTION_CREATE
public static final String ACTION_CREATE
- See Also:
CREATE
, Constant Field Values
-
ACTION_CREATE_THEN_DROP
public static final String ACTION_CREATE_THEN_DROP
- See Also:
CREATE_DROP
, Constant Field Values
-
ACTION_VALIDATE
public static final String ACTION_VALIDATE
- See Also:
VALIDATE
, Constant Field Values
-
ACTION_UPDATE
public static final String ACTION_UPDATE
- See Also:
UPDATE
, Constant Field Values
-
SPEC_ACTION_NONE
public static final String SPEC_ACTION_NONE
- See Also:
NONE
, Constant Field Values
-
SPEC_ACTION_DROP
public static final String SPEC_ACTION_DROP
- See Also:
DROP
, Constant Field Values
-
SPEC_ACTION_CREATE
public static final String SPEC_ACTION_CREATE
- See Also:
CREATE_ONLY
, Constant Field Values
-
SPEC_ACTION_DROP_AND_CREATE
public static final String SPEC_ACTION_DROP_AND_CREATE
- See Also:
CREATE
, Constant Field Values
-
-
Method Detail
-
values
public static Action[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Action c : Action.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Action valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
getExternalJpaName
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".
-
getExternalHbm2ddlName
public String getExternalHbm2ddlName()
The string configuration value identifying this action in old-school Hibernate configuration via "hibernate.hbm2ddl.auto".
-
interpretJpaSetting
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 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
public static Action interpretHbm2ddlSetting(Object value)
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
-
-