Example usage for javax.persistence InheritanceType TABLE_PER_CLASS

List of usage examples for javax.persistence InheritanceType TABLE_PER_CLASS

Introduction

In this page you can find the example usage for javax.persistence InheritanceType TABLE_PER_CLASS.

Prototype

InheritanceType TABLE_PER_CLASS

To view the source code for javax.persistence InheritanceType TABLE_PER_CLASS.

Click Source Link

Document

A table per concrete entity class.

Usage

From source file:com.jaxio.celerio.factory.InheritanceFactory.java

private void putEntityByTableNameForEntityWithInheritance() {
    // Attention, for SINGLE_TABLE inheritance strategy, we only put the root entity.

    for (EntityConfig entityConfig : config.getCelerio().getEntityConfigs()) {
        Entity entity = config.getProject().getEntityByName(entityConfig.getEntityName());

        if (entity.hasInheritance() && !config.getProject().hasEntityByTableName(entity.getTableName())) {
            InheritanceType inheritanceType = entity.getInheritance().getStrategy();

            if (inheritanceType == InheritanceType.SINGLE_TABLE) {
                if (entity.isRoot()) {
                    config.getProject().putEntityByTableName(entity);
                }/*from   ww w . j a  v a  2 s. com*/
            } else if (inheritanceType == InheritanceType.JOINED
                    || inheritanceType == InheritanceType.TABLE_PER_CLASS) {
                config.getProject().putEntityByTableName(entity);
            } else {
                log.warning("Invalid case, there should be an inheritance type");
            }
        }
    }
}