Package org.hibernate.tuple.entity
Class PojoEntityTuplizer
java.lang.Object
org.hibernate.tuple.entity.AbstractEntityTuplizer
org.hibernate.tuple.entity.PojoEntityTuplizer
- All Implemented Interfaces:
EntityTuplizer,Tuplizer
An
EntityTuplizer specific to the pojo entity mode.-
Field Summary
Fields inherited from class org.hibernate.tuple.entity.AbstractEntityTuplizer
getters, hasCustomAccessors, propertySpan, setters -
Constructor Summary
ConstructorsConstructorDescriptionPojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) Called just after the entities properties have been initialized.protected InstantiatorbuildInstantiator(PersistentClass persistentClass) Build an appropriate Instantiator for the given mapped entity.protected GetterbuildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) Build an appropriate Getter for the given property.protected SetterbuildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) Build an appropriate Setter for the given property.protected ProxyFactorybuildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) Build an appropriate ProxyFactory for the given mapped entity.protected ProxyFactorybuildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it.Returns the java class to which generated proxies will be typed.Return the entity-mode handled by this tuplizer instance.Get anyEntityNameResolversassociated with thisTuplizer.Return the pojo class managed by this tuplizer.Object[]getPropertyValues(Object entity) Extract the current values contained on the given entity.Object[]getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) Extract the values of the insertable properties of the entity (including backrefs)protected Object[]getPropertyValuesWithOptimizer(Object object) booleanhasUninitializedLazyProperties(Object entity) Does the given entity instance have any currently uninitialized lazy properties?booleanIs it an instrumented POJO?booleanbooleanDoes theclassmanaged by this tuplizer implement theValidatableinterface.voidsetPropertyValues(Object entity, Object[] values) Inject the given values into the given entity.protected voidsetPropertyValuesWithOptimizer(Object object, Object[] values) Methods inherited from class org.hibernate.tuple.entity.AbstractEntityTuplizer
createProxy, getComponentValue, getEntityMetamodel, getEntityName, getFactory, getGetter, getIdentifier, getIdentifier, getIdentifierGetter, getIdentifierMapperType, getInstantiator, getPropertyValue, getPropertyValue, getProxyFactory, getSubclassEntityNames, getVersion, getVersionGetter, hasProxy, instantiate, instantiate, instantiate, isInstance, resetIdentifier, resetIdentifier, setIdentifier, setIdentifier, setPropertyValue, setPropertyValue, shouldGetAllProperties, toString
-
Constructor Details
-
PojoEntityTuplizer
-
-
Method Details
-
buildProxyFactory
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) Build an appropriate ProxyFactory for the given mapped entity.- Specified by:
buildProxyFactoryin classAbstractEntityTuplizer- Parameters:
persistentClass- The mapping information regarding the mapped entity.idGetter- The constructed Getter relating to the entity's id property.idSetter- The constructed Setter relating to the entity's id property.- Returns:
- An appropriate ProxyFactory instance.
-
buildProxyFactoryInternal
protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) -
buildInstantiator
Build an appropriate Instantiator for the given mapped entity.- Specified by:
buildInstantiatorin classAbstractEntityTuplizer- Parameters:
persistentClass- The mapping information regarding the mapped entity.- Returns:
- An appropriate Instantiator instance.
-
setPropertyValues
Inject the given values into the given entity.- Specified by:
setPropertyValuesin interfaceTuplizer- Overrides:
setPropertyValuesin classAbstractEntityTuplizer- Parameters:
entity- The entity.values- The values to be injected.- Throws:
HibernateException
-
getPropertyValues
Extract the current values contained on the given entity.- Specified by:
getPropertyValuesin interfaceTuplizer- Overrides:
getPropertyValuesin classAbstractEntityTuplizer- Parameters:
entity- The entity from which to extract values.- Returns:
- The current property values.
- Throws:
HibernateException
-
getPropertyValuesToInsert
public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) throws HibernateException Extract the values of the insertable properties of the entity (including backrefs)- Specified by:
getPropertyValuesToInsertin interfaceEntityTuplizer- Overrides:
getPropertyValuesToInsertin classAbstractEntityTuplizer- Parameters:
entity- The entity from which to extract.mergeMap- a map of instances being merged to merged instancessession- The session in which the resuest is being made.- Returns:
- The insertable property values.
- Throws:
HibernateException
-
setPropertyValuesWithOptimizer
-
getPropertyValuesWithOptimizer
-
getEntityMode
Return the entity-mode handled by this tuplizer instance.- Returns:
- The entity-mode
-
getMappedClass
Return the pojo class managed by this tuplizer. Need to determine how to best handle this for the Tuplizers for EntityModes other than POJO. todo : be really nice to not have this here since it is essentially pojo specific...- Returns:
- The persistent class.
-
isLifecycleImplementor
public boolean isLifecycleImplementor()- Specified by:
isLifecycleImplementorin interfaceEntityTuplizer- Overrides:
isLifecycleImplementorin classAbstractEntityTuplizer- Returns:
- True if the Lifecycle interface is implemented; false otherwise.
-
isValidatableImplementor
public boolean isValidatableImplementor()Does theclassmanaged by this tuplizer implement theValidatableinterface.- Specified by:
isValidatableImplementorin interfaceEntityTuplizer- Overrides:
isValidatableImplementorin classAbstractEntityTuplizer- Returns:
- True if the Validatable interface is implemented; false otherwise.
-
buildPropertyGetter
Build an appropriate Getter for the given property.- Specified by:
buildPropertyGetterin classAbstractEntityTuplizer- Parameters:
mappedProperty- The property to be accessed via the built Getter.mappedEntity- The entity information regarding the mapped entity owning this property.- Returns:
- An appropriate Getter instance.
-
buildPropertySetter
Build an appropriate Setter for the given property.- Specified by:
buildPropertySetterin classAbstractEntityTuplizer- Parameters:
mappedProperty- The property to be accessed via the built Setter.mappedEntity- The entity information regarding the mapped entity owning this property.- Returns:
- An appropriate Setter instance.
-
getConcreteProxyClass
Returns the java class to which generated proxies will be typed. todo : look at fully encapsulatingPersistenceContext.narrowProxy(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.EntityKey, java.lang.Object)here, since that is the only external use of this method- Returns:
- The java class to which generated proxies will be typed
-
afterInitialize
public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) Called just after the entities properties have been initialized.- Specified by:
afterInitializein interfaceEntityTuplizer- Overrides:
afterInitializein classAbstractEntityTuplizer- Parameters:
entity- The entity being initialized.lazyPropertiesAreUnfetched- Are defined lazy properties currently unfecthedsession- The session initializing this entity.
-
hasUninitializedLazyProperties
Does the given entity instance have any currently uninitialized lazy properties?- Specified by:
hasUninitializedLazyPropertiesin interfaceEntityTuplizer- Overrides:
hasUninitializedLazyPropertiesin classAbstractEntityTuplizer- Parameters:
entity- The entity to be check for uninitialized lazy properties.- Returns:
- True if uninitialized lazy properties were found; false otherwise.
-
isInstrumented
public boolean isInstrumented()Is it an instrumented POJO? -
determineConcreteSubclassEntityName
public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it. This is called in situations where we already know an entity name for the given entityInstance; we are being asked to determine if there is a more appropriate entity-name to use, specifically within an inheritence hierarchy. For example, consider a case where a user calls session.update( "Animal", cat );. Here, the user has explicitly provided Animal as the entity-name. However, they have passed in an instance of Cat which is a subclass of Animal. In this case, we would return Cat as the entity-name. null may be returned from calls to this method. The meaining of null in that case is assumed to be that we should use whatever explicit entity-name the user provided (Animal rather than Cat in the example above).- Parameters:
entityInstance- The entity instance.factory- Reference to the SessionFactory.- Returns:
- The most appropriate entity name to use.
-
getEntityNameResolvers
Get anyEntityNameResolversassociated with thisTuplizer.- Returns:
- The associated resolvers. May be null or empty.
-