Skip to content

Commit

Permalink
Start of support for soft-delete, metadata extension properties and
Browse files Browse the repository at this point in the history
surrogate column enum. For #180
  • Loading branch information
andyjefferson committed Jan 25, 2017
1 parent c31cff7 commit 22725f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/org/datanucleus/metadata/MetaData.java
Expand Up @@ -74,6 +74,12 @@ public class MetaData implements Serializable
/** Class : when using multitenancy, defines the jdbc-type used for the mutitenancy discriminator column. */
public static final String EXTENSION_CLASS_MULTITENANCY_JDBC_TYPE = "multitenancy-jdbc-type";

/** Class : when the class will use soft deletion (deletion flag column) rather than actually deleting objects. */
public static final String EXTENSION_CLASS_SOFTDELETE = "softdelete";

/** Class : when the class will use soft deletion, specifies the column name to use. */
public static final String EXTENSION_CLASS_SOFTDELETE_COLUMN_NAME = "softdelete-column-name";

/** Class : define the name of a field that will store the version of this class. */
public static final String EXTENSION_CLASS_VERSION_FIELD_NAME = "field-name";

Expand Down
Expand Up @@ -85,6 +85,8 @@ public class CompleteClassTable implements Table

Column multitenancyColumn;

Column softDeleteColumn;

// TODO Support create-timestamp surrogate
// TODO Support update-timestamp surrogate
/** Map of member-column mapping, keyed by the metadata for the member. */
Expand Down Expand Up @@ -547,6 +549,8 @@ else if (mmd.hasMap())
this.multitenancyColumn = col;
}

// TODO Add soft delete column when required

// Reorder all columns to respect column positioning information. Note this assumes the user has provided complete information
List<Column> unorderedCols = new ArrayList();
Column[] cols = new Column[columns.size()];
Expand Down Expand Up @@ -1149,6 +1153,10 @@ else if (colType == SurrogateColumnType.UPDATE_TIMESTAMP)
{
// TODO Support this
}
else if (colType == SurrogateColumnType.SOFTDELETE)
{
return softDeleteColumn;
}
return null;
}

Expand Down
Expand Up @@ -27,5 +27,6 @@ public enum SurrogateColumnType
DISCRIMINATOR,
MULTITENANCY,
CREATE_TIMESTAMP,
UPDATE_TIMESTAMP
UPDATE_TIMESTAMP,
SOFTDELETE
}

0 comments on commit 22725f5

Please sign in to comment.