org.hibernate.tuple.entity
Class Dom4jEntityTuplizer

java.lang.Object
  extended by org.hibernate.tuple.entity.AbstractEntityTuplizer
      extended by org.hibernate.tuple.entity.Dom4jEntityTuplizer
All Implemented Interfaces:
EntityTuplizer, Tuplizer

public class Dom4jEntityTuplizer
extends AbstractEntityTuplizer

An EntityTuplizer specific to the dom4j entity mode.

Author:
Steve Ebersole, Gavin King

Nested Class Summary
static class Dom4jEntityTuplizer.BasicEntityNameResolver
           
 
Field Summary
 
Fields inherited from class org.hibernate.tuple.entity.AbstractEntityTuplizer
getters, hasCustomAccessors, propertySpan, setters
 
Method Summary
protected  Instantiator buildInstantiator(PersistentClass persistentClass)
          Build an appropriate Instantiator for the given mapped entity.
protected  Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
          Build an appropriate Getter for the given property.
protected  Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity)
          Build an appropriate Setter for the given property.
protected  ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
          Build an appropriate ProxyFactory for the given mapped entity.
 String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory)
          Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it.
static String extractNodeName(org.dom4j.Element element)
           
 Class getConcreteProxyClass()
          Returns the java class to which generated proxies will be typed.
 EntityMode getEntityMode()
          Return the entity-mode handled by this tuplizer instance.
 EntityNameResolver[] getEntityNameResolvers()
          Get any EntityNameResolvers associated with this Tuplizer.
 Serializable getIdentifier(Object entityOrId)
          Extract the identifier value from the given entity.
 Serializable getIdentifier(Object entityOrId, SessionImplementor session)
          Extract the identifier value from the given entity.
 Class getMappedClass()
          Return the pojo class managed by this tuplizer.
 boolean isInstrumented()
          Is it an instrumented POJO?
 
Methods inherited from class org.hibernate.tuple.entity.AbstractEntityTuplizer
afterInitialize, createProxy, getComponentValue, getEntityMetamodel, getEntityName, getFactory, getGetter, getIdentifierGetter, getIdentifierMapperType, getInstantiator, getPropertyValue, getPropertyValue, getPropertyValues, getPropertyValuesToInsert, getProxyFactory, getSubclassEntityNames, getVersion, getVersionGetter, hasProxy, hasUninitializedLazyProperties, instantiate, instantiate, instantiate, isInstance, isLifecycleImplementor, isValidatableImplementor, resetIdentifier, resetIdentifier, setIdentifier, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, shouldGetAllProperties, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getEntityMode

public EntityMode getEntityMode()
Return the entity-mode handled by this tuplizer instance.

Returns:
The entity-mode

buildPropertyGetter

protected Getter buildPropertyGetter(Property mappedProperty,
                                     PersistentClass mappedEntity)
Build an appropriate Getter for the given property.

Specified by:
buildPropertyGetter in class AbstractEntityTuplizer
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

protected Setter buildPropertySetter(Property mappedProperty,
                                     PersistentClass mappedEntity)
Build an appropriate Setter for the given property.

Specified by:
buildPropertySetter in class AbstractEntityTuplizer
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.

buildInstantiator

protected Instantiator buildInstantiator(PersistentClass persistentClass)
Build an appropriate Instantiator for the given mapped entity.

Specified by:
buildInstantiator in class AbstractEntityTuplizer
Parameters:
persistentClass - The mapping information regarding the mapped entity.
Returns:
An appropriate Instantiator instance.

getIdentifier

public Serializable getIdentifier(Object entityOrId)
                           throws HibernateException
Extract the identifier value from the given entity.

Specified by:
getIdentifier in interface EntityTuplizer
Overrides:
getIdentifier in class AbstractEntityTuplizer
Parameters:
entityOrId - The entity from which to extract the identifier value.
Returns:
The identifier value.
Throws:
HibernateException - If the entity does not define an identifier property, or an error occurs accessing its value.

getIdentifier

public Serializable getIdentifier(Object entityOrId,
                                  SessionImplementor session)
Extract the identifier value from the given entity.

Specified by:
getIdentifier in interface EntityTuplizer
Overrides:
getIdentifier in class AbstractEntityTuplizer
Parameters:
entityOrId - The entity from which to extract the identifier value.
session - The session from which is requests originates
Returns:
The identifier value.

buildProxyFactory

protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo,
                                         Getter idGetter,
                                         Setter idSetter)
Build an appropriate ProxyFactory for the given mapped entity.

Specified by:
buildProxyFactory in class AbstractEntityTuplizer
Parameters:
mappingInfo - 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.

getMappedClass

public Class 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.

getConcreteProxyClass

public Class getConcreteProxyClass()
Returns the java class to which generated proxies will be typed.

todo : look at fully encapsulating PersistenceContext.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

isInstrumented

public boolean isInstrumented()
Is it an instrumented POJO?


getEntityNameResolvers

public EntityNameResolver[] getEntityNameResolvers()
Get any EntityNameResolvers associated with this Tuplizer.

Returns:
The associated resolvers. May be null or empty.

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.

extractNodeName

public static String extractNodeName(org.dom4j.Element element)


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.