Skip to content

Commit e0cfe41

Browse files
committed
Upgrade to Postgres 11 for integration testing.
Postgres stored procedures requires some adjustments in order to upgrade to Postgres 11. See #2903
1 parent 8717db6 commit e0cfe41

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/procedures/PostgresStoredProcedureIntegrationTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.springframework.data.jpa.repository.JpaRepository;
4848
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
4949
import org.springframework.data.jpa.repository.query.Procedure;
50+
import org.springframework.data.jpa.util.DisabledOnHibernate61;
5051
import org.springframework.data.jpa.util.DisabledOnHibernate62;
5152
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
5253
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
@@ -68,6 +69,7 @@
6869
* @author Greg Turnquist
6970
* @author Yanming Zhou
7071
*/
72+
@DisabledOnHibernate61 // GH-2903
7173
@Transactional
7274
@ExtendWith(SpringExtension.class)
7375
@ContextConfiguration(classes = PostgresStoredProcedureIntegrationTests.Config.class)
@@ -203,7 +205,7 @@ static class Config {
203205
@Bean(initMethod = "start", destroyMethod = "stop")
204206
public PostgreSQLContainer<?> container() {
205207

206-
return new PostgreSQLContainer<>("postgres:10.21") //
208+
return new PostgreSQLContainer<>("postgres:15.3") //
207209
.withUsername("postgres");
208210
}
209211

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/procedures/PostgresStoredProcedureNullHandlingIntegrationTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.springframework.data.jpa.repository.Temporal;
4545
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
4646
import org.springframework.data.jpa.repository.query.Procedure;
47+
import org.springframework.data.jpa.util.DisabledOnHibernate61;
4748
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
4849
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
4950
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean;
@@ -62,6 +63,7 @@
6263
*
6364
* @author Greg Turnquist
6465
*/
66+
@DisabledOnHibernate61 // GH-2903
6567
@Transactional
6668
@ExtendWith(SpringExtension.class)
6769
@ContextConfiguration(classes = PostgresStoredProcedureNullHandlingIntegrationTests.Config.class)
@@ -109,7 +111,7 @@ static class Config {
109111
@Bean(initMethod = "start", destroyMethod = "stop")
110112
public PostgreSQLContainer<?> container() {
111113

112-
return new PostgreSQLContainer<>("postgres:10.21") //
114+
return new PostgreSQLContainer<>("postgres:15.3") //
113115
.withUsername("postgres");
114116
}
115117

spring-data-jpa/src/test/resources/scripts/postgres-nullable-stored-procedures.sql

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ CREATE TABLE test_model
66
CONSTRAINT test_model_pk PRIMARY KEY (ID)
77
);;
88

9-
CREATE OR REPLACE FUNCTION countByUuid(this_uuid uuid)
10-
RETURNS int
9+
CREATE OR REPLACE PROCEDURE countByUuid(IN this_uuid uuid)
1110
LANGUAGE 'plpgsql'
1211
AS
1312
$BODY$
@@ -18,13 +17,11 @@ BEGIN
1817
INTO c
1918
FROM test_model
2019
WHERE test_model.uuid = this_uuid;
21-
RETURN c;
2220
END;
2321
$BODY$
2422
;;
2523

26-
CREATE OR REPLACE FUNCTION countByLocalDate(this_local_date DATE)
27-
RETURNS int
24+
CREATE OR REPLACE PROCEDURE countByLocalDate(IN this_local_date DATE)
2825
LANGUAGE 'plpgsql'
2926
AS
3027
$BODY$
@@ -35,7 +32,6 @@ BEGIN
3532
INTO c
3633
FROM test_model
3734
WHERE test_model.local_date = this_local_date;
38-
RETURN c;
3935
END;
4036
$BODY$
4137
;;

spring-data-jpa/src/test/resources/scripts/postgres-stored-procedures.sql

+4-13
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,29 @@ CREATE TABLE employee
88
INSERT INTO employee (ID, NAME) VALUES (3, 'Fanny');;
99
INSERT INTO employee (ID, NAME) VALUES (4, 'Gabriel');;
1010

11-
CREATE OR REPLACE FUNCTION get_employees()
12-
RETURNS refcursor
11+
CREATE OR REPLACE PROCEDURE get_employees(OUT ref refcursor)
1312
LANGUAGE 'plpgsql'
1413
AS
1514
$BODY$
16-
DECLARE
17-
ref refcursor;
1815
BEGIN
1916
OPEN ref FOR SELECT * FROM employee;
20-
RETURN ref;
2117
END;
2218
$BODY$;;
2319

24-
CREATE OR REPLACE FUNCTION get_employees_count()
25-
RETURNS integer
20+
CREATE OR REPLACE PROCEDURE get_employees_count(OUT results integer)
2621
LANGUAGE 'plpgsql'
2722
AS
2823
$BODY$
2924
BEGIN
30-
RETURN (SELECT COUNT(*) FROM employee);
25+
results = (SELECT COUNT(*) FROM employee);
3126
END;
3227
$BODY$;;
3328

34-
CREATE OR REPLACE FUNCTION get_single_employee()
35-
RETURNS refcursor
29+
CREATE OR REPLACE PROCEDURE get_single_employee(OUT ref refcursor)
3630
LANGUAGE 'plpgsql'
3731
AS
3832
$BODY$
39-
DECLARE
40-
ref refcursor;
4133
BEGIN
4234
OPEN ref FOR SELECT * FROM employee WHERE employee.ID = 3;
43-
RETURN ref;
4435
END;
4536
$BODY$;;

0 commit comments

Comments
 (0)