Browse Source

Add sequence support for AOT dialect.

Closes #4103
pull/4108/head
Mark Paluch 2 months ago
parent
commit
74c66fd0e6
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 9
      spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/AotMetamodel.java
  2. 34
      spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotMetamodelUnitTests.java

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

@ -33,6 +33,8 @@ import org.hibernate.cfg.JdbcSettings; @@ -33,6 +33,8 @@ import org.hibernate.cfg.JdbcSettings;
import org.hibernate.cfg.PersistenceSettings;
import org.hibernate.cfg.QuerySettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.sequence.ANSISequenceSupport;
import org.hibernate.dialect.sequence.SequenceSupport;
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
@ -137,7 +139,14 @@ class AotMetamodel implements Metamodel { @@ -137,7 +139,14 @@ class AotMetamodel implements Metamodel {
*/
@SuppressWarnings("deprecation")
static class SpringDataJpaAotDialect extends Dialect {
static SpringDataJpaAotDialect INSTANCE = new SpringDataJpaAotDialect();
@Override
public SequenceSupport getSequenceSupport() {
return ANSISequenceSupport.INSTANCE;
}
}
}

34
spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/aot/AotMetamodelUnitTests.java

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
/*
* Copyright 2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jpa.repository.aot;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link AotMetamodel}.
*
* @author Mark Paluch
*/
class AotMetamodelUnitTests {
@Test // GH-4103
void dialectSupportsSequences() {
assertThat(AotMetamodel.SpringDataJpaAotDialect.INSTANCE.getSequenceSupport().supportsSequences()).isTrue();
assertThat(AotMetamodel.SpringDataJpaAotDialect.INSTANCE.getSequenceSupport().supportsPooledSequences()).isTrue();
}
}
Loading…
Cancel
Save