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".
-
-
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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getExternalHbm2ddlName()
String
getExternalJpaName()
static Action
interpretHbm2ddlSetting(Object value)
Used to interpret the value of "hibernate.hbm2ddl.auto"static Action
interpretJpaSetting(Object value)
Used when processing JPA configuration to interpret the user config values.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.Valid in JPA; compatible with Hibernate's HBM2DDL action of the same name.
-
CREATE_ONLY
public static final Action CREATE_ONLY
Create the schema.This is an action introduced by JPA; Hibernate's legacy HBM2DDL had no such action. Its "create" action was actually equivalent to
CREATE
.- See Also:
SchemaCreator
-
DROP
public static final Action DROP
Drop the schema.Valid in JPA; compatible with Hibernate's HBM2DDL action of the same name.
- See Also:
SchemaDropper
-
CREATE
public static final Action CREATE
Drop and then recreate the schema.- See Also:
SchemaDropper
,SchemaCreator
-
CREATE_DROP
public static final Action CREATE_DROP
Drop the schema and then recreate it onSessionFactory
startup. Additionally, drop the schema onSessionFactory
shutdown.This action is not defined by JPA.
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
-
VALIDATE
public static final Action VALIDATE
Validate the database schema.This action is not defined by JPA.
- See Also:
SchemaValidator
-
UPDATE
public static final Action UPDATE
Update (alter) the database schema.This action is not defined by JPA.
- See Also:
SchemaMigrator
-
TRUNCATE
public static final Action TRUNCATE
Truncate the tables in the schema.This action is not defined by JPA.
- Since:
- 6.2
- See Also:
SchemaTruncator
-
-
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()
-
getExternalHbm2ddlName
public String getExternalHbm2ddlName()
-
interpretJpaSetting
public static Action interpretJpaSetting(Object value)
Used when processing JPA configuration to interpret the user config values. Generally this will be a value specified by "jakarta.persistence.schema-generation.database.action" or "jakarta.persistence.schema-generation.scripts.action"- 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)
Used to interpret the value of "hibernate.hbm2ddl.auto"- 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
-
-