forked from Impetus/kundera
-
Notifications
You must be signed in to change notification settings - Fork 0
Mapped SuperClass Support
chhavigangwal edited this page Oct 18, 2013
·
14 revisions
Mapped super class is used to define state and mapping information that is common to multiple entity classes.It is a super class which does not have any separate table.It is never be a part of persistent relationship and can be concrete or an abstract class. Kundera, being a JPA provider supports Mapped super class.
In order to become a stronger JPA provider Kundera has also enabled support of Mapped Superclasses and Inheritance strategy.
@MappedSuperclass
@Table(name = "TRNX")
public class Transaction
{
@Id
private String txId;
@Column
private String bankIdentifier;
@Column
private Date transactionDt;
@Entity
@Table(name = "TRNX")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "tx_type")
public class Transaction extends AbstractTransaction
{
@Column
private String bankIdentifier;
It can be implemented in two ways :
- Discriminator column
- Attribute Override
Sample Use Case : 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);
Benefits :
- Mapped Superclass and inheritance Strategy enable tradition normalized relational database schema support.
To-do :
- No join table support enabled
-
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] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with--Couchdb)
- [Kundera with Elasticsearch] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Elasticsearch)
- [Kundera with HBase] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-HBase)
- [Kundera with Kudu] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Kudu)
- [Kundera with MongoDB] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-MongoDB)
- [Kundera with OracleNoSQL] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-OracleNoSQL)
- [Kundera with Redis] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-over-Redis)
- [Kundera with Spark] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Spark)
-
Extend Kundera
- Sample Codes and Examples
- [Blogs and Articles] (https://github.com/impetus-opensource/Kundera/wiki/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