To configure a JPALoader or JPAEntityLoader, see Plug-ins for communicating with databases.
Configure a JPATxCallback transaction callback along with the loader
configuration. The following example is an ObjectGrid XML descriptor file
(objectgrid.xml), that has a JPAEntityLoader and
JPATxCallback configured:
configuring a loader including callback - XML example
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="JPAEM" entityMetadataXMLFile="jpaEMD.xml">
<bean id="TransactionCallback"
className="com.ibm.websphere.objectgrid.jpa.JPATxCallback">
<property
name="persistenceUnitName"
type="java.lang.String"
value="employeeEMPU" />
</bean>
<backingMap name="Employee" pluginCollectionRef="Employee" />
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="Employee">
<bean id="Loader"
className="com.ibm.websphere.objectgrid.jpa.JPAEntityLoader">
<property
name="entityClassName"
type="java.lang.String"
value="com.ibm.ws.objectgrid.jpa.test.entity.Employee"/>
</bean>
</backingMapPluginCollection>
</backingMapPluginCollections>
</objectGridConfig>
If you want to configure a JPAPropertyFactory, you have to use a Spring style
configuration. The following is an XML configuration file
sample,JPAEM_spring.xml which configures a Spring bean to be used for eXtreme Scale configurations.
configuring a loader including JPA property factory - XML example
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:objectgrid="http://www.ibm.com/schema/objectgrid"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<objectgrid:JPAEntityLoader id="jpaLoader"
entityClassName="com.ibm.ws.objectgrid.jpa.test.entity.Employee"/>
<objectgrid:JPATxCallback id="jpaTxCallback" persistenceUnitName="employeeEMPU" />
</beans>
The Objectgrid.xml configuration XML file follows. Notice the ObjectGrid
name is JPAEM, which matches the ObjectGrid name in the
JPAEM_spring.xml Spring configuration file.
JPAEM loader configuration - XML example
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="JPAEM" entityMetadataXMLFile="jpaEMD.xml">
<bean id="TransactionCallback"
className="{spring}jpaTxCallback"/>
<backingMap name="Employee" pluginCollectionRef="Employee"
writeBehind="T4"/>
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="Employee">
<bean id="Loader" className="{spring}jpaLoader" />
</backingMapPluginCollection>
</backingMapPluginCollections>
</objectGridConfig>
An entity can be annotated with both the JPA annotations and eXtreme Scale entity manager annotations. Each annotation has an XML
equivalent that can be used. Thus, eXtreme Scale added the Spring
namespace. You can also configure these using the Spring namespace support. For more information,
see Spring framework overview.