Skip to content

Commit 775b120

Browse files
committed
Add sequence support for AOT dialect.
Closes #4103
1 parent afff932 commit 775b120

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.hibernate.cfg.PersistenceSettings;
3434
import org.hibernate.cfg.QuerySettings;
3535
import org.hibernate.dialect.Dialect;
36+
import org.hibernate.dialect.sequence.ANSISequenceSupport;
37+
import org.hibernate.dialect.sequence.SequenceSupport;
3638
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
3739
import org.hibernate.jpa.HibernatePersistenceProvider;
3840
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
@@ -137,7 +139,14 @@ public EntityManagerFactory getEntityManagerFactory() {
137139
*/
138140
@SuppressWarnings("deprecation")
139141
static class SpringDataJpaAotDialect extends Dialect {
142+
140143
static SpringDataJpaAotDialect INSTANCE = new SpringDataJpaAotDialect();
144+
145+
@Override
146+
public SequenceSupport getSequenceSupport() {
147+
return ANSISequenceSupport.INSTANCE;
148+
}
149+
141150
}
142151

143152
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.jpa.repository.aot;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
20+
import org.junit.jupiter.api.Test;
21+
22+
/**
23+
* Unit tests for {@link AotMetamodel}.
24+
*
25+
* @author Mark Paluch
26+
*/
27+
class AotMetamodelUnitTests {
28+
29+
@Test // GH-4103
30+
void dialectSupportsSequences() {
31+
assertThat(AotMetamodel.SpringDataJpaAotDialect.INSTANCE.getSequenceSupport().supportsSequences()).isTrue();
32+
assertThat(AotMetamodel.SpringDataJpaAotDialect.INSTANCE.getSequenceSupport().supportsPooledSequences()).isTrue();
33+
}
34+
}

0 commit comments

Comments
 (0)