mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-18053 TiDB timestampadd/diff pattern for fractional seconds
This commit is contained in:
parent
f45a7975c4
commit
5e9223ee5c
@ -11,6 +11,8 @@
|
|||||||
import org.hibernate.dialect.sequence.TiDBSequenceSupport;
|
import org.hibernate.dialect.sequence.TiDBSequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.query.sqm.IntervalType;
|
||||||
|
import org.hibernate.query.sqm.TemporalUnit;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
||||||
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
||||||
@ -19,6 +21,8 @@
|
|||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorTiDBDatabaseImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorTiDBDatabaseImpl;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@linkplain Dialect SQL dialect} for TiDB.
|
* A {@linkplain Dialect SQL dialect} for TiDB.
|
||||||
*
|
*
|
||||||
@ -177,4 +181,22 @@ public String getForUpdateNowaitString(String aliases) {
|
|||||||
public FunctionalDependencyAnalysisSupport getFunctionalDependencyAnalysisSupport() {
|
public FunctionalDependencyAnalysisSupport getFunctionalDependencyAnalysisSupport() {
|
||||||
return FunctionalDependencyAnalysisSupportImpl.TABLE_REFERENCE;
|
return FunctionalDependencyAnalysisSupportImpl.TABLE_REFERENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
|
||||||
|
if ( unit == TemporalUnit.SECOND ) {
|
||||||
|
// TiDB doesn't natively support adding fractional seconds
|
||||||
|
return "timestampadd(microsecond,?2*1e6,?3)";
|
||||||
|
}
|
||||||
|
return super.timestampaddPattern( unit, temporalType, intervalType );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
||||||
|
if ( unit == TemporalUnit.SECOND ) {
|
||||||
|
// TiDB doesn't natively support adding fractional seconds
|
||||||
|
return "timestampadd(microsecond,?2*1e6,?3)";
|
||||||
|
}
|
||||||
|
return super.timestampdiffPattern( unit, fromTemporalType, toTemporalType );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user