001package io.ebean.config.dbplatform; 002 003/** 004 * History support for the database platform. 005 */ 006public interface DbHistorySupport { 007 008 /** 009 * Return true if the implementation is SQL2011 standards based. 010 * <p> 011 * Non standards based means we need to add additional predicates into the 012 * JOIN ON clause and add an additional predicate for the base table. 013 * </p> 014 */ 015 boolean isStandardsBased(); 016 017 /** 018 * Return the number of columns bound in a 'As Of' predicate. 019 * <p> 020 * This is 1 for more standard sql2011 style and Postgres which has the 021 * special range type and 2 for view based solutions with 2 columns such as 022 * MySql. 023 * </p> 024 */ 025 int getBindCount(); 026 027 /** 028 * For sql2011 style this ignores the passed in view suffix and returns something 029 * like the ' as of timestamp ?' clause to be appended after the base table name. 030 * 031 * @param asOfViewSuffix the configured view suffix (typically "_with_history"). 032 * @return The suffix appended after the base table name in the from and join clauses. 033 */ 034 String getAsOfViewSuffix(String asOfViewSuffix); 035 036 /** 037 * Return the 'versions between timestamp' suffix. 038 */ 039 String getVersionsBetweenSuffix(String asOfViewSuffix); 040 041 /** 042 * Return the 'as of' predicate added for the given table alias. 043 * 044 * @param tableAlias The table alias this predicate is added for 045 * @param sysPeriod The name of the 'sys_period' column used for effective date time range. 046 * @return The predicate containing a single ? bind parameter which will be bound to the 'as at' timestamp value 047 */ 048 String getAsOfPredicate(String tableAlias, String sysPeriod); 049 050 /** 051 * Return the column for the system period lower bound that will be included in findVersions() queries. 052 * 053 * @param tableAlias the table alias which will typically be 't0' 054 * @param sysPeriod the name of the sys_period column 055 */ 056 String getSysPeriodLower(String tableAlias, String sysPeriod); 057 058 /** 059 * Return the column for the system period upper bound that will be included in findVersions() queries. 060 * 061 * @param tableAlias the table alias which will typically be 't0' 062 * @param sysPeriod the name of the sys_period column 063 */ 064 String getSysPeriodUpper(String tableAlias, String sysPeriod); 065 066}