|
7 | 7 | package org.hibernate.community.dialect;
|
8 | 8 |
|
9 | 9 | import java.sql.Types;
|
| 10 | +import java.time.temporal.TemporalAccessor; |
| 11 | +import java.util.Date; |
| 12 | +import java.util.TimeZone; |
10 | 13 |
|
11 | 14 | import org.hibernate.boot.Metadata;
|
12 | 15 | import org.hibernate.boot.model.FunctionContributions;
|
|
74 | 77 | import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
75 | 78 | import org.hibernate.type.spi.TypeConfiguration;
|
76 | 79 |
|
| 80 | +import jakarta.persistence.TemporalType; |
| 81 | + |
77 | 82 | import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
78 | 83 | import static org.hibernate.type.SqlTypes.BIGINT;
|
79 | 84 | import static org.hibernate.type.SqlTypes.BINARY;
|
|
88 | 93 | import static org.hibernate.type.SqlTypes.TINYINT;
|
89 | 94 | import static org.hibernate.type.SqlTypes.VARBINARY;
|
90 | 95 | import static org.hibernate.type.SqlTypes.VARCHAR;
|
| 96 | +import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_END; |
| 97 | +import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_DATE; |
| 98 | +import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_TIME; |
| 99 | +import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_TIMESTAMP; |
| 100 | +import static org.hibernate.type.descriptor.DateTimeUtils.appendAsDate; |
| 101 | +import static org.hibernate.type.descriptor.DateTimeUtils.appendAsLocalTime; |
| 102 | +import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTime; |
| 103 | +import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithMicros; |
91 | 104 |
|
92 | 105 | /**
|
93 | 106 | * Dialect for Informix 7.31.UD3 with Informix
|
@@ -234,6 +247,11 @@ public int getDefaultTimestampPrecision() {
|
234 | 247 | return 5;
|
235 | 248 | }
|
236 | 249 |
|
| 250 | + @Override |
| 251 | + public boolean doesRoundTemporalOnOverflow() { |
| 252 | + return false; |
| 253 | + } |
| 254 | + |
237 | 255 | @Override
|
238 | 256 | public int getFloatPrecision() {
|
239 | 257 | return 8;
|
@@ -718,6 +736,56 @@ public static Replacer datetimeFormat(String format) {
|
718 | 736 | .replace("S", "%F1");
|
719 | 737 | }
|
720 | 738 |
|
| 739 | + @Override |
| 740 | + public void appendDateTimeLiteral( |
| 741 | + SqlAppender appender, |
| 742 | + TemporalAccessor temporalAccessor, |
| 743 | + TemporalType precision, |
| 744 | + TimeZone jdbcTimeZone) { |
| 745 | + switch ( precision ) { |
| 746 | + case DATE: |
| 747 | + appender.appendSql( JDBC_ESCAPE_START_DATE ); |
| 748 | + appendAsDate( appender, temporalAccessor ); |
| 749 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 750 | + break; |
| 751 | + case TIME: |
| 752 | + appender.appendSql( JDBC_ESCAPE_START_TIME ); |
| 753 | + appendAsTime( appender, temporalAccessor, supportsTemporalLiteralOffset(), jdbcTimeZone ); |
| 754 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 755 | + break; |
| 756 | + case TIMESTAMP: |
| 757 | + appender.appendSql( JDBC_ESCAPE_START_TIMESTAMP ); |
| 758 | + appendAsTimestampWithMicros( appender, temporalAccessor, supportsTemporalLiteralOffset(), jdbcTimeZone ); |
| 759 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 760 | + break; |
| 761 | + default: |
| 762 | + throw new IllegalArgumentException(); |
| 763 | + } |
| 764 | + } |
| 765 | + |
| 766 | + @Override |
| 767 | + public void appendDateTimeLiteral(SqlAppender appender, Date date, TemporalType precision, TimeZone jdbcTimeZone) { |
| 768 | + switch ( precision ) { |
| 769 | + case DATE: |
| 770 | + appender.appendSql( JDBC_ESCAPE_START_DATE ); |
| 771 | + appendAsDate( appender, date ); |
| 772 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 773 | + break; |
| 774 | + case TIME: |
| 775 | + appender.appendSql( JDBC_ESCAPE_START_TIME ); |
| 776 | + appendAsLocalTime( appender, date ); |
| 777 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 778 | + break; |
| 779 | + case TIMESTAMP: |
| 780 | + appender.appendSql( JDBC_ESCAPE_START_TIMESTAMP ); |
| 781 | + appendAsTimestampWithMicros( appender, date, jdbcTimeZone ); |
| 782 | + appender.appendSql( JDBC_ESCAPE_END ); |
| 783 | + break; |
| 784 | + default: |
| 785 | + throw new IllegalArgumentException(); |
| 786 | + } |
| 787 | + } |
| 788 | + |
721 | 789 | @Override
|
722 | 790 | public String getSelectClauseNullString(int sqlType, TypeConfiguration typeConfiguration) {
|
723 | 791 | DdlType descriptor = typeConfiguration.getDdlTypeRegistry().getDescriptor( sqlType );
|
|
0 commit comments