-
Notifications
You must be signed in to change notification settings - Fork 233
Mapped SuperClass Support
Mapped super class is used to define state and mapping information that is common to multiple entity classes.For further details refer
In order to become a stronger JPA provider and enable support of traditional normalized schema Kundera has also enabled support of Mapped Superclasses and Inheritance strategy.
Sample Transaction use case
A sample class annotated with @MappedSuperclass .This class ca be inherited by specific transaction type entities and its attributes can be overridden.
@MappedSuperclass
public class Transaction
{
@Id
private String txId;
@Column
private String bankIdentifier;
@Column
private Date transactionDt;
CreditTransaction :
@Entity
@Table(name = "TRNX_CREDIT")
@AttributeOverride(name="bankIdentifier",column= @Column(name="CREDIT_BANK_IDENT"))
@IndexCollection(columns={@Index(name="bankIdentifier")})
public class CreditTransaction extends Transaction
{
@Column
private Integer amount;
@Column
@Enumerated(EnumType.STRING)
private Status txStatus;
DebitTransaction :
@Entity
@AttributeOverride(name="bankIdentifier",column= @Column(name="CREDIT_BANK_IDENT"))
@IndexCollection(columns={@Index(name="bankIdentifier")})
public class DebitTransaction extends Transaction
{
@Column
private Integer amount;
@Column
@Enumerated(EnumType.STRING)
private Status txStatus;
Sample Transaction Use Case : A sample class annotated with @Entity .This class is inherited by specific transaction type entities and depending on inheritance strategy the data is persisted accordingly.
@Entity
@Table(name = "TRNX")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "tx_type")
public class Transaction extends AbstractTransaction
{
@Column
private String bankIdentifier;
CreditTransaction :
@Entity
@Table(name = "TRNX_CREDIT")
@DiscriminatorValue(value = "CREDIT")
@AttributeOverride(name="bankIdentifier",column= @Column(name="CREDIT_BANK_IDENT"))
@IndexCollection(columns={@Index(name="bankIdentifier")})
public class CreditTransaction extends Transaction
{
@Column
private Integer amount;
@Column
@Enumerated(EnumType.STRING)
private Status txStatus;
Debit Transaction :
@Entity
@DiscriminatorValue(value="DEBIT")
@AttributeOverrides(value = { @AttributeOverride(name = "txId", column = @Column(name = "DEBIT_ID")),
@AttributeOverride(name = "bankIdentifier", column = @Column(name = "DEBIT_BANK_IDENT")),
@AttributeOverride(name = "transactionDt", column = @Column(name = "TX_DT")) })
public class DebitTransaction extends Transaction
{
@Column
private Integer amount;
Entity Transaction :
CreditTransaction creditTx = new CreditTransaction();
creditTx.setTxId("credit1");
creditTx.setTxStatus(Status.APPROVED);
creditTx.setBankIdentifier("sbi");
creditTx.setTransactionDt(new Date());
creditTx.setAmount(10);
em.persist(creditTx);
waitThread(wait);
DebitTransaction debitTx = new DebitTransaction();
debitTx.setTxId("debit1");
debitTx.setTxStatus(Status.PENDING);
debitTx.setTransactionDt(new Date());
debitTx.setBankIdentifier("sbi");
debitTx.setAmount(-10);
em.persist(debitTx);
waitThread(wait);
em.clear();
String creditQuery = "Select c from CreditTransaction c where c.bankIdentifier = 'sbi'";
Query query = em.createQuery(creditQuery);
List<CreditTransaction> results = query.getResultList();
Assert.assertEquals(1, results.size());
Assert.assertEquals("credit1", results.get(0).getTxId());
em.clear();
String debitQuery = "Select d from DebitTransaction d where d.bankIdentifier = 'sbi'";
query = em.createQuery(debitQuery);
List<DebitTransaction> debitResults = query.getResultList();
Assert.assertEquals(1, debitResults.size());
Assert.assertEquals("debit1", debitResults.get(0).getTxId());
Benefits :
- Mapped Superclass and inheritance Strategy will enable the traditional(normalized) relational database migration to NoSQL.
To-do :
- Enable join table support
-
Datastores Supported
- Releases
-
Architecture
-
Concepts
-
Getting Started in 5 minutes
-
Features
- Object Mapper
- Polyglot Persistence
- Queries Support
- JPQL (JPA Query Language)
- Native Queries
- Batch insert update
- Schema Generation
- Primary Key Auto generation
- Transaction Management
- REST Based Access
- Geospatial Persistence and Queries
- Graph Database Support
-
Composite Keys
-
No hard annotation for schema
-
Support for Mapped superclass
-
Object to NoSQL Data Mapping
-
Cassandra's User Defined Types and Indexes on Collections
-
Support for aggregation
- Scalar Queries over Cassandra
- Connection pooling using Kundera Cassandra
- Configuration
-
Kundera with Couchdb
-
Kundera with Elasticsearch
-
Kundera with HBase
-
Kundera with Kudu
-
Kundera with RethinkDB
-
Kundera with MongoDB
-
Kundera with OracleNoSQL
-
Kundera with Redis
-
Kundera with Spark
-
Extend Kundera
- Sample Codes and Examples
-
Blogs and Articles
-
Tutorials
* Kundera with Openshift
* Kundera with Play Framework
* Kundera with GWT
* Kundera with JBoss
* Kundera with Spring
-
Performance
-
Troubleshooting
-
FAQ
- Production deployments
- Feedback