#384 - ENH: Add findVersionsBetween(start, end) ... including implementation support for Oracle total recall

This commit is contained in:
Robin Bygrave committed 2015-08-18 23:57:11 +12:00
1 parent 75e9770d5e
commit 580b51381e
16 files changed
+170 -19

No files matched your search

@@ -133,6 +133,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
*/
private final String baseTable;
private final String baseTableAsOf;
private final String baseTableVersionsBetween;
private final boolean historySupport;
/**
@@ -354,6 +355,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
this.historySupport = deploy.isHistorySupport();
this.baseTable = InternString.intern(deploy.getBaseTable());
this.baseTableAsOf = deploy.getBaseTableAsOf();
this.baseTableVersionsBetween = deploy.getBaseTableVersionsBetween();
this.autoFetchTunable = EntityType.ORM.equals(entityType) && (beanFinder == null);
// helper object used to derive lists of properties
@@ -1686,7 +1688,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
*/
public String getBaseTable(SpiQuery.TemporalMode mode) {
switch (mode) {
case VERSIONS: return baseTableAsOf;
case VERSIONS: return baseTableVersionsBetween;
case AS_OF: return baseTableAsOf;
default: return baseTable;
}
@@ -176,7 +176,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
this.eagerFetchLobs = serverConfig.isEagerFetchLobs();
this.asOfViewSuffix = getAsOfViewSuffix(databasePlatform, serverConfig);
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix);
String versionsBetweenSuffix = getVersionsBetweenSuffix(databasePlatform, serverConfig);
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix);
this.bootupClasses = config.getBootupClasses();
this.createProperties = config.getDeployCreateProperties();
this.namingConvention = serverConfig.getNamingConvention();
@@ -201,8 +202,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
}
/**
* Return the AsOfViewSuffix allowing the DbHistorySupport to override the value in
* the case where there is no view (Oracle, DB2, MS SQL Server).
* Return the AsOfViewSuffix based on the DbHistorySupport.
*/
private String getAsOfViewSuffix(DatabasePlatform databasePlatform, ServerConfig serverConfig) {
@@ -211,6 +211,16 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
return (historySupport == null ) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
}
/**
* Return the versions between timestamp suffix based on the DbHistorySupport.
*/
private String getVersionsBetweenSuffix(DatabasePlatform databasePlatform, ServerConfig serverConfig) {
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
return (historySupport == null ) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
}
public BeanDescriptor<?> getBeanDescriptorById(String descriptorId) {
return idDescMap.get(descriptorId);
}
@@ -1029,7 +1039,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
if (!EntityType.ORM.equals(desc.getEntityType())) {
// not using base table
desc.setBaseTable(null, null);
desc.setBaseTable(null, null, null);
}
// mark transient properties
@@ -115,6 +115,8 @@ public class DeployBeanDescriptor<T> {
private String baseTableAsOf;
private String baseTableVersionsBetween;
private boolean historySupport;
private TableName baseTableFull;
@@ -464,10 +466,20 @@ public class DeployBeanDescriptor<T> {
return baseTable;
}
/**
* Return the base table with as of suffix.
*/
public String getBaseTableAsOf() {
return baseTableAsOf;
}
/**
* Return the base table with versions between suffix.
*/
public String getBaseTableVersionsBetween() {
return baseTableVersionsBetween;
}
/**
* Return the base table with full structure.
*/
@@ -478,10 +490,11 @@ public class DeployBeanDescriptor<T> {
/**
* Set the base table. Only properties mapped to the base table are by default persisted.
*/
public void setBaseTable(TableName baseTableFull, String asOfSuffix) {
public void setBaseTable(TableName baseTableFull, String asOfSuffix, String versionsBetweenSuffix) {
this.baseTableFull = baseTableFull;
this.baseTable = baseTableFull == null ? null : baseTableFull.getQualifiedName();
this.baseTableAsOf = baseTable + asOfSuffix;
this.baseTableVersionsBetween = baseTable + versionsBetweenSuffix;
}
public void sortProperties() {
@@ -29,9 +29,12 @@ public class AnnotationClass extends AnnotationParser {
private final String asOfViewSuffix;
public AnnotationClass(DeployBeanInfo<?> info, boolean validationAnnotations, String asOfViewSuffix) {
private final String versionsBetweenSuffix;
public AnnotationClass(DeployBeanInfo<?> info, boolean validationAnnotations, String asOfViewSuffix, String versionsBetweenSuffix) {
super(info, validationAnnotations);
this.asOfViewSuffix = asOfViewSuffix;
this.versionsBetweenSuffix = versionsBetweenSuffix;
}
/**
@@ -52,7 +55,7 @@ public class AnnotationClass extends AnnotationParser {
// default the TableName using NamingConvention.
TableName tableName = namingConvention.getTableName(descriptor.getBeanType());
descriptor.setBaseTable(tableName, asOfViewSuffix);
descriptor.setBaseTable(tableName, asOfViewSuffix, versionsBetweenSuffix);
}
}
@@ -21,6 +21,8 @@ public class ReadAnnotations {
*/
private final String asOfViewSuffix;
private final String versionsBetweenSuffix;
/**
* True if the javax validation annotations are present in the classpath.
*/
@@ -31,9 +33,10 @@ public class ReadAnnotations {
*/
private final boolean jacksonAnnotations;
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix) {
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix) {
this.generatedPropFactory = generatedPropFactory;
this.asOfViewSuffix = asOfViewSuffix;
this.versionsBetweenSuffix = versionsBetweenSuffix;
this.javaxValidationAnnotations = ClassUtil.isJavaxValidationAnnotationsPresent();
this.jacksonAnnotations = ClassUtil.isJacksonAnnotationsPresent();
}
@@ -48,12 +51,11 @@ public class ReadAnnotations {
public void readInitial(DeployBeanInfo<?> info, boolean eagerFetchLobs) {
try {
new AnnotationClass(info, javaxValidationAnnotations, asOfViewSuffix).parse();
new AnnotationClass(info, javaxValidationAnnotations, asOfViewSuffix, versionsBetweenSuffix).parse();
new AnnotationFields(generatedPropFactory, info, javaxValidationAnnotations, jacksonAnnotations, eagerFetchLobs).parse();
} catch (RuntimeException e) {
String msg = "Error reading annotations for " + info;
throw new RuntimeException(msg, e);
throw new RuntimeException("Error reading annotations for " + info, e);
}
}