com.adaptrex.core.persistence.jpa
Class JpaPersistence

java.lang.Object
  extended by com.adaptrex.core.persistence.jpa.JpaPersistence
All Implemented Interfaces:
AdaptrexPersistence

public class JpaPersistence
extends Object
implements AdaptrexPersistence


Constructor Summary
JpaPersistence()
           
 
Method Summary
 Object deleteEntity(String entityName, Integer id)
          This should delete an entity from the default 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(String entityName, Integer id)
          This should return a single entity object from the default 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).
 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.
 javax.persistence.EntityManager getEntityManager()
          This should return the default entity manager for whichever implementation is being used.
 Object getFieldValue(Object entity, String fieldName)
           
 boolean isIdField(Class<?> clazz, String fieldName)
           
 boolean isManyToOne(Class<?> clazz, String fieldName)
           
 boolean isOneToMany(Class<?> clazz, String fieldName)
           
 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
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaPersistence

public JpaPersistence()
Method Detail

shutdown

public void shutdown()
Specified by:
shutdown in interface AdaptrexPersistence

getEntityClass

public Class<?> getEntityClass(String className)
Description copied from interface: AdaptrexPersistence
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.

Specified by:
getEntityClass in interface AdaptrexPersistence
Returns:

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Description copied from interface: AdaptrexPersistence
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.

Specified by:
getEntityManager in interface AdaptrexPersistence
Returns:

getEntity

public Object getEntity(String entityName,
                        Integer id)
Description copied from interface: AdaptrexPersistence
This should return a single entity object from the default persistence unit based on the supplied className and id

Specified by:
getEntity in interface AdaptrexPersistence
Returns:

getEntity

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

Specified by:
getEntity in interface AdaptrexPersistence
Returns:

saveEntity

public Object saveEntity(Object entity)
Description copied from interface: AdaptrexPersistence
This should save (create or update) the supplied entity using the default persistence unit and return an updated instance of the entity

Specified by:
saveEntity in interface AdaptrexPersistence
Returns:

deleteEntity

public Object deleteEntity(String entityName,
                           Integer id)
Description copied from interface: AdaptrexPersistence
This should delete an entity from the default persistence unit based on the supplied className and id

Specified by:
deleteEntity in interface AdaptrexPersistence
Returns:

getEntityList

public List<Object> getEntityList(Store store)
Description copied from interface: AdaptrexPersistence
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

Specified by:
getEntityList in interface AdaptrexPersistence
Returns:

isIdField

public boolean isIdField(Class<?> clazz,
                         String fieldName)
Specified by:
isIdField in interface AdaptrexPersistence

isOneToMany

public boolean isOneToMany(Class<?> clazz,
                           String fieldName)
Specified by:
isOneToMany in interface AdaptrexPersistence

isManyToOne

public boolean isManyToOne(Class<?> clazz,
                           String fieldName)
Specified by:
isManyToOne in interface AdaptrexPersistence

getFieldValue

public Object getFieldValue(Object entity,
                            String fieldName)
Specified by:
getFieldValue in interface AdaptrexPersistence


Copyright © 2012 Adaptrex, LLC. All Rights Reserved.