com.adaptrex.core.persistence
Interface AdaptrexPersistence

All Known Implementing Classes:
JpaPersistence

@ApplicationScoped
public interface AdaptrexPersistence

AdaptrexPersistence provides an interface to an variety of implementations that handle persistence between Adaptrex and an ORM. Currently only a standard JPA2 (via EclipseLink) implentation is included but he eventual goal is to allow nearly any ORM to be supported (Hibernate, Cayanne, TopLink, OpenJpa, etc, etc).

Some of the code in adaptrex-core that uses this API is currently JPA specific. com.adaptrex.core.ext.data.ModelInstance scans its target entity several times and reads JPA annotations to determine things like join types and the type of objects being retrieved. The AdaptrexPersistence interface should be made much more robust to handle this functionality and current functionality should move to the JPA specific implementation.

Because this API is not yet 100% stable, it should only be used inside other adaptrex-core code


Method Summary
 Object deleteEntity(String className, Integer id)
          This should delete an entity from the default persistence unit based on the supplied className and id
 Object deleteEntity(String className, Integer id, String persistenceUnitName)
          This should delete an entity from the specified persistence unit based on the supplied className and id
 Object getEntity(Class<?> clazz, Integer id)
          This should return a single entity object from the default persistence unit based on the supplied class and id
 Object getEntity(Class<?> clazz, Integer id, String persistenceUnitName)
          This should return a single entity object from the specified persistence unit based on the supplied class and id
 Object getEntity(String className, Integer id)
          This should return a single entity object from the default persistence unit based on the supplied className and id
 Object getEntity(String className, Integer id, String persistenceUnitName)
          This should return a single entity from the specified persistence unit based on the supplied className and id
 Class<?> getEntityClass(String className)
          This should return the class for a specific className in the default persistence unit (JPA Persistence Unit, Hibernate session, etc, etc).
 Class<?> getEntityClass(String className, String persistenceUnitName)
          This should return the class for a specific className in the specified persistence unit (JPA Persistence Unit, Hibernate session, etc, etc).
 List<Object> getEntityList(Store store)
          This should return a list of objects that comprise the data that is to be included in an ext.data.Store.
 List<Object> getEntityList(Store store, String persistenceUnitName)
          This should return a list of objects from the default persistence unit that comprise the data that is to be included in an ext.data.Store.
 Object getEntityManager()
          This should return the default entity manager for whichever implementation is being used.
 Object getEntityManager(String persistenceUnitName)
          This should return the specified entity manager for whichever implementation is being used.
 Object getFieldValue(Object entity, String fieldName)
           
 Object getFieldValue(Object entity, String fieldName, String persistenceUnitName)
           
 boolean isIdField(Class<?> clazz, String fieldName)
           
 boolean isIdField(Class<?> clazz, String fieldName, String persistenceUnitName)
           
 boolean isManyToOne(Class<?> clazz, String fieldName)
           
 boolean isManyToOne(Class<?> clazz, String fieldName, String persistenceUnitName)
           
 boolean isOneToMany(Class<?> clazz, String fieldName)
           
 boolean isOneToMany(Class<?> clazz, String fieldName, String persistenceUnitName)
           
 Object saveEntity(Object entity)
          This should save (create or update) the supplied entity using the default persistence unit and return an updated instance of the entity
 Object saveEntity(Object entity, String persistenceUnitName)
          This should save (create or update) the supplied entity using the specified persistence unit and return an updated instance of the entity
 

Method Detail

getEntityClass

Class<?> getEntityClass(String className)
This should return the class for a specific className in the default persistence unit (JPA Persistence Unit, Hibernate session, etc, etc). It should accept just the simple name assuming there is only one class with that name in the persistence unit. It should also accept a fully qualified name in situations where the persistence unit has multiple classes with the same name in different packages.

Parameters:
className -
Returns:

getEntityClass

Class<?> getEntityClass(String className,
                        String persistenceUnitName)
This should return the class for a specific className in the specified persistence unit (JPA Persistence Unit, Hibernate session, etc, etc). It should accept just the simple name assuming there is only one class with that name in the persistence unit. It should also accept a fully qualified name in situations where the persistence unit has multiple classes with the same name in different packages.

Parameters:
className -
Returns:

getEntityList

List<Object> getEntityList(Store store,
                           String persistenceUnitName)
This should return a list of objects from the default persistence unit that comprise the data that is to be included in an ext.data.Store. The Store object contains a significant number of configuration options that should be used to generate the store. Any implementation should support all possible store options.

TODO: document the possible store options each implementation should be aware of

Parameters:
store -
Returns:

getEntityList

List<Object> getEntityList(Store store)
This should return a list of objects that comprise the data that is to be included in an ext.data.Store. The Store object contains a significant number of configuration options that should be used to generate the store. Any implementation should support all possible store options.

TODO: document the possible store options each implementation should be aware of

Parameters:
store -
Returns:

getEntity

Object getEntity(String className,
                 Integer id)
This should return a single entity object from the default persistence unit based on the supplied className and id

Parameters:
className -
id -
Returns:

getEntity

Object getEntity(String className,
                 Integer id,
                 String persistenceUnitName)
This should return a single entity from the specified persistence unit based on the supplied className and id

Parameters:
className -
id -
Returns:

getEntity

Object getEntity(Class<?> clazz,
                 Integer id)
This should return a single entity object from the default persistence unit based on the supplied class and id

Parameters:
class -
id -
Returns:

getEntity

Object getEntity(Class<?> clazz,
                 Integer id,
                 String persistenceUnitName)
This should return a single entity object from the specified persistence unit based on the supplied class and id

Parameters:
class -
id -
Returns:

saveEntity

Object saveEntity(Object entity)
This should save (create or update) the supplied entity using the default persistence unit and return an updated instance of the entity

Parameters:
entity -
Returns:

saveEntity

Object saveEntity(Object entity,
                  String persistenceUnitName)
This should save (create or update) the supplied entity using the specified persistence unit and return an updated instance of the entity

Parameters:
entity -
Returns:

deleteEntity

Object deleteEntity(String className,
                    Integer id)
This should delete an entity from the default persistence unit based on the supplied className and id

Parameters:
className -
id -
Returns:

deleteEntity

Object deleteEntity(String className,
                    Integer id,
                    String persistenceUnitName)
This should delete an entity from the specified persistence unit based on the supplied className and id

Parameters:
className -
id -
Returns:

getEntityManager

Object getEntityManager()
This should return the default entity manager for whichever implementation is being used. For example. JPA should return an EntityManager. Hibernate should return a Session. Cayenne should return an ObjectContext.

The AdaptrexPersistence interface currently contains a subset of functions required by adaptrex itself. Individual applications may require more control and access to the specific ORM implementation.

Returns:

getEntityManager

Object getEntityManager(String persistenceUnitName)
This should return the specified entity manager for whichever implementation is being used. For example. JPA should return an EntityManager. Hibernate should return a Session. Cayenne should return an ObjectContext.

The AdaptrexPersistence interface currently contains a subset of functions required by adaptrex itself. Individual applications may require more control and access to the specific ORM implementation.

Returns:

isIdField

boolean isIdField(Class<?> clazz,
                  String fieldName)

isIdField

boolean isIdField(Class<?> clazz,
                  String fieldName,
                  String persistenceUnitName)

isOneToMany

boolean isOneToMany(Class<?> clazz,
                    String fieldName)

isOneToMany

boolean isOneToMany(Class<?> clazz,
                    String fieldName,
                    String persistenceUnitName)

isManyToOne

boolean isManyToOne(Class<?> clazz,
                    String fieldName)

isManyToOne

boolean isManyToOne(Class<?> clazz,
                    String fieldName,
                    String persistenceUnitName)

getFieldValue

Object getFieldValue(Object entity,
                     String fieldName)

getFieldValue

Object getFieldValue(Object entity,
                     String fieldName,
                     String persistenceUnitName)


Copyright © 2012 Adaptrex, LLC. All Rights Reserved.