Skip to content

Commit 0e9c237

Browse files
committed
Polishing.
Add support for limit/offset and implement introspection methods to avoid throwing UnsupportedOperationException. See #4103
1 parent 775b120 commit 0e9c237

File tree

1 file changed

+26
-0
lines changed
  • spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot

1 file changed

+26
-0
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/AotMetamodel.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import jakarta.persistence.EntityManager;
1919
import jakarta.persistence.EntityManagerFactory;
20+
import jakarta.persistence.TemporalType;
2021
import jakarta.persistence.metamodel.EmbeddableType;
2122
import jakarta.persistence.metamodel.EntityType;
2223
import jakarta.persistence.metamodel.ManagedType;
@@ -33,12 +34,15 @@
3334
import org.hibernate.cfg.PersistenceSettings;
3435
import org.hibernate.cfg.QuerySettings;
3536
import org.hibernate.dialect.Dialect;
37+
import org.hibernate.dialect.pagination.LimitHandler;
38+
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
3639
import org.hibernate.dialect.sequence.ANSISequenceSupport;
3740
import org.hibernate.dialect.sequence.SequenceSupport;
3841
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
3942
import org.hibernate.jpa.HibernatePersistenceProvider;
4043
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
4144
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
45+
import org.hibernate.query.common.TemporalUnit;
4246
import org.jspecify.annotations.Nullable;
4347
import org.springframework.data.util.Lazy;
4448
import org.springframework.orm.jpa.persistenceunit.PersistenceManagedTypes;
@@ -142,11 +146,33 @@ static class SpringDataJpaAotDialect extends Dialect {
142146

143147
static SpringDataJpaAotDialect INSTANCE = new SpringDataJpaAotDialect();
144148

149+
public boolean isCurrentTimestampSelectStringCallable() {
150+
return false;
151+
}
152+
153+
public String getCurrentTimestampSelectString() {
154+
return "call current_timestamp()";
155+
}
156+
157+
@Override
158+
public LimitHandler getLimitHandler() {
159+
return OffsetFetchLimitHandler.INSTANCE;
160+
}
161+
145162
@Override
146163
public SequenceSupport getSequenceSupport() {
147164
return ANSISequenceSupport.INSTANCE;
148165
}
149166

167+
@Override
168+
@SuppressWarnings("deprecation")
169+
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
170+
if (unit == null) {
171+
return "(?3-?2)";
172+
}
173+
return "datediff(?1,?2,?3)";
174+
}
175+
150176
}
151177

152178
}

0 commit comments

Comments
 (0)