|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.beanlib.hibernate3.Hibernate3DtoCopier
public class Hibernate3DtoCopier
Hibernate 3 Data Transfer Object Copier.
A simple facade of HibernateBeanReplicator
,
this class provides a simplified (but limited) API for the common use cases
to conveniently replicate Hibernate objects
that follow the JavaBean getter/setter convention on a best attempt basis.
Those application specific Hibernate objects would typically have the same package prefix.
The replication is typically recursive in that the whole object graph of the input object is replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary. However, the exact behavior of the replication process can be controlled and/or supplemented by the client code via 3 main options:
Hibernate3BeanReplicator
directly.
Hibernate3BeanReplicator
Field Summary | |
---|---|
private String |
applicationPackagePrefix
An entity bean under a package with a name that matches this prefix will be included for replication, eagerly fetched if necessary. |
Constructor Summary | |
---|---|
Hibernate3DtoCopier()
Constructs with application package prefix disabled. |
|
Hibernate3DtoCopier(String applicationPackagePrefix)
Constructs with an application package prefix. |
|
Hibernate3DtoCopier(String applicationPackagePrefix,
Class<?> applicationSampleClass)
Constructs with an application package prefix, and a sample application class in a package with such prefix for sanity checking purposes. |
Method Summary | ||
---|---|---|
private
|
copy(Class<E> targetEntityType,
Object from,
Class<?>[] interestedEntityTypes)
Returns a DTO of the specified target entity type by partially cloning the object graph of the given Hibernate "from" instance that follows the JavaBean getter/setter convention on a best attempt basis, excluding all collection and map properties. |
|
private
|
copy(Class<E> targetEntityType,
Object from,
Class<?>[] interestedEntityTypes,
CollectionPropertyName<?>[] collectionPropertyNames)
Returns a DTO of the specified target entity type by partially cloning the object graph of the given Hibernate "from" instance that follows the JavaBean getter/setter convention on a best attempt basis, including only those properties that are explicitly specified, or implied by the application package prefix. |
|
private Object |
copy(Object from,
Class<?>[] interestedEntityTypes)
Returns a DTO by partially cloning the object graph of the given Hibernate "from" instance that follows the JavaBean getter/setter convention on a best attempt basis, excluding all collection and map properties. |
|
protected Hibernate3BeanReplicator |
createHibernateBeanReplicator()
Returns the implementation instance that performs the actual replication. |
|
|
hibernate2dto(Class<E> targetEntityType,
Collection<?> hibernateBeans,
Class<?>[] interestedEntityTypes,
CollectionPropertyName<?>[] collectionPropertyNames)
Returns a list of DTO's of the specified target entity type by partially cloning the object graphs of the given collection of Hibernate entity beans that follows the JavaBean getter/setter convention on a best attempt basis, including only those properties that are explicitly specified, or implied by the application package prefix. |
|
|
hibernate2dto(Class<E> targetEntityType,
T entityBean)
Returns a DTO of the specified target entity type by cloning portion of the object graph of the given Hibernate bean, excluding all collection and map properties, and including only those properties with package names that match the application package prefix. |
|
|
hibernate2dto(Class<E> targetEntityType,
T from,
Class<?>[] interestedEntityTypes,
CollectionPropertyName<?>[] collectionPropertyNames)
Returns a DTO of the specified target entity type by partially cloning the object graphs of the given Hibernate "from" instance that follows the JavaBean getter/setter convention on a best attempt basis, including only those properties that are explicitly specified, or implied by the application package prefix. |
|
List<?> |
hibernate2dto(Collection<?> hibernateBeans)
Returns a list of DTO's by partially cloning the object graphs of the given collection of Hibernate entity beans, excluding all collection and map properties, and including only those properties with package names that match the application package prefix. |
|
|
hibernate2dto(Object entityBean)
Returns a DTO by cloning portion of the object graph of the given Hibernate bean, excluding all collection and map properties, and including only those properties with package names that match the application package prefix. |
|
|
hibernate2dto(T from,
Class<?>[] interestedEntityTypes,
CollectionPropertyName<?>[] collectionPropertyNames)
Returns a DTO by partially cloning the object graph of the given Hibernate "from" instance that follows the JavaBean getter/setter convention on a best attempt basis, including only those properties that are explicitly specified, or implied by the application package prefix. |
|
List<?> |
hibernate2dtoFully(Collection<?> hibernateBeans)
Returns a list of DTO's by deep cloning the application specific entities of the given collection of Hibernate beans. |
|
|
hibernate2dtoFully(Object from)
Returns a DTO by deep cloning the application specific entities of the given Hibernate "from" instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final String applicationPackagePrefix
Constructor Detail |
---|
public Hibernate3DtoCopier()
public Hibernate3DtoCopier(String applicationPackagePrefix)
applicationPackagePrefix
public Hibernate3DtoCopier(String applicationPackagePrefix, Class<?> applicationSampleClass)
IllegalArgumentException
- if the given application package prefix
does not match the package of the given sample application class.applicationPackagePrefix
Method Detail |
---|
protected Hibernate3BeanReplicator createHibernateBeanReplicator()
public <T> T hibernate2dtoFully(Object from)
If you need to "blindly" deep clone the entire object graph,
consider using hibernate2dto(Class, Object, Class[], CollectionPropertyName[])
specifying null for the interstedPropertyTypes and collectionPropertyNames.
public List<?> hibernate2dtoFully(Collection<?> hibernateBeans)
If you need to "blindly" deep clone the entire object graph,
consider using hibernate2dto(Class, Collection, Class[], CollectionPropertyName[])
specifying null for the interstedPropertyTypes and collectionPropertyNames.
public <T> T hibernate2dto(Object entityBean)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
entityBean
- Hibernate entity bean to be clonedapplicationPackagePrefix
public <E,T> E hibernate2dto(Class<E> targetEntityType, T entityBean)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
targetEntityType
- target entity typeentityBean
- Hibernate entity bean to be clonedapplicationPackagePrefix
public <T> T hibernate2dto(T from, Class<?>[] interestedEntityTypes, CollectionPropertyName<?>[] collectionPropertyNames)
from
- given Hibernate entity bean to be clonedinterestedEntityTypes
- properties of these types will be included for cloningcollectionPropertyNames
- collection and map properties to be included in the cloningapplicationPackagePrefix
public <E,T> E hibernate2dto(Class<E> targetEntityType, T from, Class<?>[] interestedEntityTypes, CollectionPropertyName<?>[] collectionPropertyNames)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
targetEntityType
- target entity typefrom
- given Hibernate entity bean to be clonedinterestedEntityTypes
- properties of these types will be included for cloningcollectionPropertyNames
- collection and map properties to be included in the cloningapplicationPackagePrefix
public List<?> hibernate2dto(Collection<?> hibernateBeans)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
hibernateBeans
- given collection of Hibernate Beans.applicationPackagePrefix
public <E> List<E> hibernate2dto(Class<E> targetEntityType, Collection<?> hibernateBeans, Class<?>[] interestedEntityTypes, CollectionPropertyName<?>[] collectionPropertyNames)
hibernateBeans
- given collection of Hibernate entity beans to be clonedinterestedEntityTypes
- properties of these types will be included for cloningcollectionPropertyNames
- collection and map properties to be included in the cloningapplicationPackagePrefix
private Object copy(Object from, Class<?>[] interestedEntityTypes)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
from
- given entity bean to be clonedinterestedEntityTypes
- properties of these types will be included for cloningapplicationPackagePrefix
private <E> E copy(Class<E> targetEntityType, Object from, Class<?>[] interestedEntityTypes)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
targetEntityType
- target entity typefrom
- given entity bean to be clonedinterestedEntityTypes
- properties of these types will be included for cloningapplicationPackagePrefix
private <E> E copy(Class<E> targetEntityType, Object from, Class<?>[] interestedEntityTypes, CollectionPropertyName<?>[] collectionPropertyNames)
The replication is typically recursive in that the object graph of the input object is basically replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
targetEntityType
- target entity typefrom
- given Hibernate entity bean to be clonedinterestedEntityTypes
- properties of these types will be included for cloningcollectionPropertyNames
- collection and map properties to be included in the cloningapplicationPackagePrefix
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |