Class ImplHelper
java.lang.Object
org.apache.openjpa.util.ImplHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClose the given resource.static ObjectgenerateFieldValue(StoreContext ctx, FieldMetaData fmd) Generate a value for the given metadata, or return null.static ObjectgenerateIdentityValue(StoreContext ctx, ClassMetaData meta, int typeCode) Generate a value for the given metadata, or return null.static Class<?> getEntityClass(Object obj) Returns the entity class for the given object, unwrapping any runtime-generated pcsubclass proxy.static Objectstatic BitSetReturns the fields of the state that require an update.static booleanisAssignable(Class from, Class to) Returns true if the referenced "to" class is assignable to the "from" class.static booleanisManageable(Object instance) Returns true if the specified instance is manageable.static booleanisManagedType(OpenJPAConfiguration conf, Class type) Returns true if the specified class is a type that can be managed by OpenJPA.static CollectionloadAll(Collection sms, StoreManager store, PCState state, int load, FetchConfiguration fetch, Object context) Helper for store manager implementations.static voidRe-registers aReflectingPersistenceCapableagainst the instance it manages, for example after deserialization.static voidregisterUnenhancedInstance(Object instance, PersistenceCapable pc) Registers thePersistenceCapableinstance that manages the state of the given raw, unenhanced instance, so that subsequent calls totoPersistenceCapable(Object, Object)for that instance resolve topcinstead of creating a newReflectingPersistenceCapable.static PersistenceCapabletoPersistenceCapable(Object o, Object ctx)
-
Constructor Details
-
ImplHelper
public ImplHelper()
-
-
Method Details
-
loadAll
public static Collection loadAll(Collection sms, StoreManager store, PCState state, int load, FetchConfiguration fetch, Object context) Helper for store manager implementations. This method simply delegates to the proper singular method for each state manager.- Since:
- 0.4.0
- See Also:
-
generateIdentityValue
Generate a value for the given metadata, or return null. Generates values for hte following strategies:ValueStrategies.SEQUENCE,ValueStrategies.UUID_STRING,ValueStrategies.UUID_HEX -
generateFieldValue
Generate a value for the given metadata, or return null. Generates values for hte following strategies:ValueStrategies.SEQUENCE,ValueStrategies.UUID_STRING,ValueStrategies.UUID_HEX -
getUpdateFields
Returns the fields of the state that require an update.- Parameters:
sm- the state to check- Returns:
- the BitSet of fields that need update, or null if none
-
close
Close the given resource. The resource can be an extent iterator, query result, large result set relation, or any closeable OpenJPA component. -
isManagedType
Returns true if the specified class is a type that can be managed by OpenJPA.- Parameters:
type- the class to test- Returns:
- true if the class is manageable.
- Since:
- 1.0.0
-
isManageable
Returns true if the specified instance is manageable.- Parameters:
instance- the object to check- Returns:
- true if the instance is a persistent type, false otherwise
-
isAssignable
Returns true if the referenced "to" class is assignable to the "from" class. This helper method utilizes a cache to help avoid the overhead of the Class.isAssignableFrom() method.- Parameters:
from- target class instance to be checked for assignabilityto- second class instance to be checked for assignability- Returns:
- true if the "to" class is assignable to the "from" class
-
toPersistenceCapable
- Returns:
- the persistence-capable instance responsible for managing
o, ornullifois not manageable. - Since:
- 1.0.0
-
registerUnenhancedInstance
Registers thePersistenceCapableinstance that manages the state of the given raw, unenhanced instance, so that subsequent calls totoPersistenceCapable(Object, Object)for that instance resolve topcinstead of creating a newReflectingPersistenceCapable.Instances are keyed by identity rather than by
Object.equals(Object), so value-based types such as records can be used as keys. Any mapping already present for the instance is replaced.pcis not required to reportinstanceas its managed instance; for a record embeddable it is the embedded copy carrying the state manager.- Parameters:
instance- the raw, unenhanced managed instancepc- the persistence-capable instance to resolve it to- Since:
- 4.2.0
-
registerPersistenceCapable
Re-registers aReflectingPersistenceCapableagainst the instance it manages, for example after deserialization.- Parameters:
pc- the persistence-capable instance to register- See Also:
-
getManagedInstance
-
getEntityClass
Returns the entity class for the given object, unwrapping any runtime-generated pcsubclass proxy. For runtime-enhanced entities,obj.getClass()returns the generated subclass (e.g.Order$pcsubclass), but forequals()/hashCode()comparisons the original entity class should be used. Generated subclass names are detected viaPCEnhancer.isPCSubclassName(String), and superclasses are walked until a class that was not generated by the enhancer is reached, so nested generated subclasses are unwrapped as well.- Parameters:
obj- the object whose entity class to determine- Returns:
- the original entity class (superclass of pcsubclass), or the object's actual class if it is not a pcsubclass
- Since:
- 4.2.0
-