org.spicefactory.pimento.provider
Class HibernateJpaProvider

java.lang.Object
  extended by org.spicefactory.pimento.provider.HibernateJpaProvider
All Implemented Interfaces:
JpaProvider

public class HibernateJpaProvider
extends Object
implements JpaProvider

JpaProvider implementation for Hibernate. Uses Hibernates Metadata API for creating the entity metadata required by Pimento.

Author:
Jens Halm

Constructor Summary
HibernateJpaProvider(EntityManagerFactory entityManagerFactory)
          Creates a new instance.
 
Method Summary
 List<EntityMetadata> getMetadata(MetadataFactory factory, Set<Operation> defaultOperations, boolean manageAllEntities)
          Creates metadata for all persistent entities managed by Pimento.
 Class<?> getPersistentClass(Object entity)
          Returns the persistent class for the specified entity.
 boolean isUninitializedProxy(Object proxy)
          Checks whether the specified entity is an uninitialized proxy.
 void setSupportedCustomTypes(Map<Class<? extends org.hibernate.usertype.UserType>,Class<? extends PropertyType>> supportedCustomTypes)
          Adds mappings from custom Hibernate UserType implementations to Pimento PropertyTypes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateJpaProvider

public HibernateJpaProvider(EntityManagerFactory entityManagerFactory)
Creates a new instance.

Parameters:
entityManagerFactory - the EntityManagerFactory to use
Method Detail

setSupportedCustomTypes

public void setSupportedCustomTypes(Map<Class<? extends org.hibernate.usertype.UserType>,Class<? extends PropertyType>> supportedCustomTypes)
Adds mappings from custom Hibernate UserType implementations to Pimento PropertyTypes. You can use an existing PropertyType or create a new one. In the latter case you'd also need to write a corresponding AS3 PropertyType and map the two in the Pimento configuration as a Cinnamon Bean Mapping.

Parameters:
supportedCustomTypes - a map of custom types

getMetadata

public List<EntityMetadata> getMetadata(MetadataFactory factory,
                                        Set<Operation> defaultOperations,
                                        boolean manageAllEntities)
Description copied from interface: JpaProvider
Creates metadata for all persistent entities managed by Pimento.

Implementations must inspect all entities configured for JPA. If the @Managed annotation is present the entity must be included in the returned metadata collection.

Furthermore properties annotated with @Hidden must be excluded from the managed properties.

Specified by:
getMetadata in interface JpaProvider
Parameters:
factory - the factory to use for creating EntityMetadataBuilder instances
defaultOperations - the operations permitted for the EntityManager remote service
manageAllEntities - whether all entities should be managed by Pimento, even if no Managed annotation is present
Returns:
metadata instances for all managed persistent entities

isUninitializedProxy

public boolean isUninitializedProxy(Object proxy)
Description copied from interface: JpaProvider
Checks whether the specified entity is an uninitialized proxy.

Specified by:
isUninitializedProxy in interface JpaProvider
Parameters:
proxy - the entity to check
Returns:
true if the specified entity is an uninitialized proxy

getPersistentClass

public Class<?> getPersistentClass(Object entity)
Description copied from interface: JpaProvider
Returns the persistent class for the specified entity.

Specified by:
getPersistentClass in interface JpaProvider
Parameters:
entity - the entity to return the persistent class for
Returns:
the persistent class for the specified entity