Package org.apache.openjpa.persistence
Class JPAProperties
- java.lang.Object
-
- org.apache.openjpa.persistence.JPAProperties
-
public class JPAProperties extends java.lang.Object
Enumerates configuration property keys defined in JPA 2.0 Specification.
Provides static utility functions to read their values from supplied map of properties.
Provides static utility functions to convert them to values that are fit for OpenJPA implementation.- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CACHE_MODE
static java.lang.String
CACHE_RETRIEVE_MODE
static java.lang.String
CACHE_STORE_MODE
static java.lang.String
DATASOURCE
static java.lang.String
DATASOURCE_JTA
static java.lang.String
DATASOURCE_NONJTA
static java.lang.String
JDBC_DRIVER
static java.lang.String
JDBC_PASSWORD
static java.lang.String
JDBC_URL
static java.lang.String
JDBC_USER
static java.lang.String
LOCK_SCOPE
static java.lang.String
LOCK_TIMEOUT
static java.lang.String
PREFIX
static java.lang.String
PROVIDER
static java.lang.String
QUERY_TIMEOUT
static java.lang.String
TRANSACTION_TYPE
static java.lang.String
VALIDATE_FACTORY
static java.lang.String
VALIDATE_GROUP_DEFAULT
static java.lang.String
VALIDATE_MODE
static java.lang.String
VALIDATE_PRE_PERSIST
static java.lang.String
VALIDATE_PRE_REMOVE
static java.lang.String
VALIDATE_PRE_UPDATE
-
Constructor Summary
Constructors Constructor Description JPAProperties()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
convertToKernelValue(java.lang.Class<T> resultType, java.lang.String key, java.lang.Object value)
Convert the given user value to a value consumable by OpenJPA kernel constructs.static java.lang.Object
convertToUserValue(java.lang.String key, java.lang.Object value)
Convert the given kernel value to a value visible to the user.static java.lang.String
getBeanProperty(java.lang.String key)
Gets a bean-style property name from the given key.static <E extends java.lang.Enum<E>>
EgetEnumValue(java.lang.Class<E> type, E[] values, java.lang.Object val)
Gets a enum value of the given type from the given value.static <E extends java.lang.Enum<E>>
EgetEnumValue(java.lang.Class<E> type, E[] values, java.lang.String key, java.util.Map<java.lang.String,java.lang.Object> prop)
Gets a enum value of the given type from the given properties looking up with the given key.static <E extends java.lang.Enum<E>>
EgetEnumValue(java.lang.Class<E> type, java.lang.Object val)
Gets a enum value of the given type from the given value.static <E extends java.lang.Enum<E>>
EgetEnumValue(java.lang.Class<E> type, java.lang.String key, java.util.Map<java.lang.String,java.lang.Object> prop)
Get the value of the given key from the given properties after converting it to the given enumerated value.static boolean
isValidKey(java.lang.String key)
Is the given key appears to be a valid JPA specification defined key?
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
PROVIDER
public static final java.lang.String PROVIDER
- See Also:
- Constant Field Values
-
TRANSACTION_TYPE
public static final java.lang.String TRANSACTION_TYPE
- See Also:
- Constant Field Values
-
DATASOURCE
public static final java.lang.String DATASOURCE
- See Also:
- Constant Field Values
-
DATASOURCE_JTA
public static final java.lang.String DATASOURCE_JTA
- See Also:
- Constant Field Values
-
DATASOURCE_NONJTA
public static final java.lang.String DATASOURCE_NONJTA
- See Also:
- Constant Field Values
-
JDBC_DRIVER
public static final java.lang.String JDBC_DRIVER
- See Also:
- Constant Field Values
-
JDBC_URL
public static final java.lang.String JDBC_URL
- See Also:
- Constant Field Values
-
JDBC_USER
public static final java.lang.String JDBC_USER
- See Also:
- Constant Field Values
-
JDBC_PASSWORD
public static final java.lang.String JDBC_PASSWORD
- See Also:
- Constant Field Values
-
LOCK_SCOPE
public static final java.lang.String LOCK_SCOPE
- See Also:
- Constant Field Values
-
LOCK_TIMEOUT
public static final java.lang.String LOCK_TIMEOUT
- See Also:
- Constant Field Values
-
QUERY_TIMEOUT
public static final java.lang.String QUERY_TIMEOUT
- See Also:
- Constant Field Values
-
CACHE_MODE
public static final java.lang.String CACHE_MODE
- See Also:
- Constant Field Values
-
CACHE_STORE_MODE
public static final java.lang.String CACHE_STORE_MODE
- See Also:
- Constant Field Values
-
CACHE_RETRIEVE_MODE
public static final java.lang.String CACHE_RETRIEVE_MODE
- See Also:
- Constant Field Values
-
VALIDATE_FACTORY
public static final java.lang.String VALIDATE_FACTORY
- See Also:
- Constant Field Values
-
VALIDATE_MODE
public static final java.lang.String VALIDATE_MODE
- See Also:
- Constant Field Values
-
VALIDATE_PRE_PERSIST
public static final java.lang.String VALIDATE_PRE_PERSIST
- See Also:
- Constant Field Values
-
VALIDATE_PRE_REMOVE
public static final java.lang.String VALIDATE_PRE_REMOVE
- See Also:
- Constant Field Values
-
VALIDATE_PRE_UPDATE
public static final java.lang.String VALIDATE_PRE_UPDATE
- See Also:
- Constant Field Values
-
VALIDATE_GROUP_DEFAULT
public static final java.lang.String VALIDATE_GROUP_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isValidKey
public static boolean isValidKey(java.lang.String key)
Is the given key appears to be a valid JPA specification defined key?- Returns:
- true if the given string merely prefixed with
jakarta.persistence.
. Does not really check all the keys defined in the specification.
-
getBeanProperty
public static java.lang.String getBeanProperty(java.lang.String key)
Gets a bean-style property name from the given key.- Parameters:
key
- must begin with JPA property prefixjakarta.persistence
- Returns:
- concatenates each part of the string leaving out
jakarta.persistence.
prefix. Part of string is what appears between DOT character.
-
convertToKernelValue
public static <T> T convertToKernelValue(java.lang.Class<T> resultType, java.lang.String key, java.lang.Object value)
Convert the given user value to a value consumable by OpenJPA kernel constructs.- Returns:
- the same value if the given key is not a valid JPA property key or the value is null.
-
convertToUserValue
public static java.lang.Object convertToUserValue(java.lang.String key, java.lang.Object value)
Convert the given kernel value to a value visible to the user.- Returns:
- the same value if the given key is not a valid JPA property key or the value is null.
-
getEnumValue
public static <E extends java.lang.Enum<E>> E getEnumValue(java.lang.Class<E> type, java.lang.String key, java.util.Map<java.lang.String,java.lang.Object> prop)
Get the value of the given key from the given properties after converting it to the given enumerated value.
-
getEnumValue
public static <E extends java.lang.Enum<E>> E getEnumValue(java.lang.Class<E> type, E[] values, java.lang.String key, java.util.Map<java.lang.String,java.lang.Object> prop)
Gets a enum value of the given type from the given properties looking up with the given key. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.- Returns:
- null if the key does not exist in the given properties.
-
getEnumValue
public static <E extends java.lang.Enum<E>> E getEnumValue(java.lang.Class<E> type, java.lang.Object val)
Gets a enum value of the given type from the given value. Converts the original value from a String, if necessary.- Returns:
- null if the key does not exist in the given properties.
-
getEnumValue
public static <E extends java.lang.Enum<E>> E getEnumValue(java.lang.Class<E> type, E[] values, java.lang.Object val)
Gets a enum value of the given type from the given value. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.- Returns:
- null if the key does not exist in the given properties.
-
-