Add tablespace support for DB2

This commit is contained in:
Roland Praml committed 2022-03-22 17:03:38 +01:00
1 parent baddc76961
commit 3e4cc3b3d6
38 files changed
+1014 -27

No files matched your search

@@ -121,6 +121,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private final boolean softDelete;
private final String draftTable;
private final PartitionMeta partitionMeta;
private final TablespaceMeta tablespaceMeta;
private final String storageEngine;
private final String dbComment;
private final boolean readAuditing;
@@ -275,6 +276,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
this.dependentTables = deploy.getDependentTables();
this.dbComment = deploy.getDbComment();
this.partitionMeta = deploy.getPartitionMeta();
this.tablespaceMeta = deploy.getTablespaceMeta();
this.storageEngine = deploy.getStorageEngine();
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
// helper object used to derive lists of properties
@@ -2671,6 +2673,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
public PartitionMeta partitionMeta() {
return partitionMeta;
}
/**
* Return the tablespace details of the bean.
*/
public TablespaceMeta tablespaceMeta() {
return tablespaceMeta;
}
/**
* Return the storage engine.
@@ -0,0 +1,59 @@
package io.ebeaninternal.server.deploy;
import java.util.Objects;
/**
* Meta data for table spaces. If table space is configured, tablespaceName, indexTablespace, lobTablespace is never null;
*
* @author Noemi Szemenyei, FOCONIS AG
*
*/
public final class TablespaceMeta {
private final String tablespaceName;
private final String indexTablespace;
private final String lobTablespace;
public TablespaceMeta(String tablespaceName, String indexTablespace, String lobTablespace) {
this.tablespaceName = tablespaceName;
this.indexTablespace = indexTablespace;
this.lobTablespace = lobTablespace;
}
public String getTablespaceName() {
return tablespaceName;
}
public String getIndexTablespace() {
return indexTablespace;
}
public String getLobTablespace() {
return lobTablespace;
}
@Override
public int hashCode() {
return Objects.hash(indexTablespace, tablespaceName, lobTablespace);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TablespaceMeta other = (TablespaceMeta) obj;
return Objects.equals(indexTablespace, other.indexTablespace)
&& Objects.equals(tablespaceName, other.tablespaceName)
&& Objects.equals(lobTablespace, other.lobTablespace);
}
@Override
public String toString() {
return "tablespace=" + tablespaceName + ", indexTablespace=" + indexTablespace + ", lobTablespace=" + lobTablespace;
}
}
@@ -32,6 +32,7 @@ import io.ebeaninternal.server.deploy.IndexDefinition;
import io.ebeaninternal.server.deploy.InheritInfo;
import io.ebeaninternal.server.deploy.PartitionMeta;
import io.ebeaninternal.server.deploy.TableJoin;
import io.ebeaninternal.server.deploy.TablespaceMeta;
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
@@ -135,6 +136,7 @@ public class DeployBeanDescriptor<T> {
private ChangeLogFilter changeLogFilter;
private String dbComment;
private PartitionMeta partitionMeta;
private TablespaceMeta tablespaceMeta;
/**
* One of NONE, INDEX or EMBEDDED.
*/
@@ -252,6 +254,14 @@ public class DeployBeanDescriptor<T> {
}
return partitionMeta;
}
public void setTablespaceMeta(TablespaceMeta tablespaceMeta) {
this.tablespaceMeta = tablespaceMeta;
}
public TablespaceMeta getTablespaceMeta() {
return tablespaceMeta;
}
public void setDraftable() {
draftable = true;
@@ -12,6 +12,7 @@ import io.ebean.annotation.Index;
import io.ebean.annotation.InvalidateQueryCache;
import io.ebean.annotation.ReadAudit;
import io.ebean.annotation.StorageEngine;
import io.ebean.annotation.Tablespace;
import io.ebean.annotation.View;
import io.ebean.config.TableName;
import io.ebeaninternal.api.CoreLog;
@@ -19,6 +20,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
import io.ebeaninternal.server.deploy.IndexDefinition;
import io.ebeaninternal.server.deploy.InheritInfo;
import io.ebeaninternal.server.deploy.PartitionMeta;
import io.ebeaninternal.server.deploy.TablespaceMeta;
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.AttributeOverride;
@@ -154,6 +156,18 @@ final class AnnotationClass extends AnnotationParser {
if (partition != null) {
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
}
Tablespace tablespace = typeGet(cls, Tablespace.class);
if (tablespace != null) {
String indexTs = tablespace.index();
if("".equals(indexTs)) {
indexTs = tablespace.value();
}
String lobTs = tablespace.lob();
if("".equals(lobTs)) {
lobTs = tablespace.value();
}
descriptor.setTablespaceMeta(new TablespaceMeta(tablespace.value(), indexTs, lobTs));
}
Draftable draftable = typeGet(cls, Draftable.class);
if (draftable != null) {
descriptor.setDraftable();