Skip to content

Persistence Providers

regunathb edited this page Nov 8, 2012 · 2 revisions

Trooper Persistence library is designed around Entities (domain objects) and PersistenceProvider(s) that are mostly interchangeable. Implementations include SQL and NoSQL providers.

See Persistence Framework for details around design and usage of the persistence libraries.

Common Maven artifacts

The following common Maven artifacts are required across all persistence providers

GroupID/Org ArtifactID/Name Description
org.trpr platform-model XML schema project that defines common data types/structures
org.trpr platform-core Core API for persistence and default implementations where relevant. Also includes features like sharding and mapping persistence entities to providers.

Maven artifacts of specific Persistence Provider implementations

Each of the following Maven artifacts are data-store specific implementations of the Persistence Provider API.

GroupID/Org ArtifactID/Name Description
org.trpr dataaccess-orm RDBMS persistence provider built over Hibernate ORM library
org.trpr dataaccess-hbase Hadoop HBase persistence provider built over the HBase Java client library. Provides XML based mapping of entities to HBase table, column families and columns.

Persistence Provider Examples

The examples below show representative usage of the persistence providers:

RDBMS (ORM) provider

The Persistence Sharding page demonstrates an example of using the RDBMS provider that is implemented over Hibernate ORM library.

HBase provider

This example Trooper Batch Job demonstrates using the HBase persistence provider to perform CRUD operations in HBase:

Trooper/examples/example-hbase/src/main/resources/external/hbaseTestTaskletJob/spring-batch-config.xml

The sample below shows XML based mapping of entities to HBase (in a manner similar to Hibernate ORM):

<?xml version="1.0" encoding="UTF-8"?>
<hbase-mapping
xmlns="http://org/trpr/dataaccess/hbase/model/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">	
    <hbase-class name="org.trpr.example.batch.hbase.test.entity.HBaseEarthling" table="mytable">
        <rowkey-definition valueAttribute="uid" valueType="java.lang.String" />
        <column-definition columnFamily="demodata" columnQualifier="name" valueAttribute="name" valueType="java.lang.String" />
        <column-definition columnFamily="demodata" columnQualifier="intValue" valueAttribute="intValue" valueType="java.lang.Integer" />
        <column-definition columnFamily="demodata" columnQualifier="longValue" valueAttribute="longValue" valueType="java.lang.Long" />
        <column-definition columnFamily="demodata" columnQualifier="byteArrayValue" valueAttribute="byteArrayValue" valueType="byte[]" />
        <column-definition columnFamily="demodata" columnQualifier="dateValue" valueAttribute="dateValue" valueType="java.util.Date" />
    </hbase-class>
</hbase-mapping>