Skip to content

Commit a9f1836

Browse files
committed
Test against Java 21 on CI.
To make this code work with Java 21, delombok the test suite. Original Pull Request: #2993
1 parent 80916d4 commit a9f1836

20 files changed

+575
-112
lines changed

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pipeline {
4848
when {
4949
beforeAgent(true)
5050
allOf {
51-
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
51+
branch(pattern: "issue/gh-java21|main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
5252
not { triggeredBy 'UpstreamCause' }
5353
}
5454
}

ci/pipeline.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Java versions
22
java.main.tag=17.0.6_10-jdk-focal
3-
java.next.tag=20-jdk-jammy
3+
java.next.tag=21-jdk-bullseye
44

55
# Docker container images - standard
66
docker.java.main.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag}
7-
docker.java.next.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.next.tag}
7+
docker.java.next.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/openjdk:${java.next.tag}
88

99
# Supported versions of MongoDB
1010
docker.mongodb.4.4.version=4.4.18

spring-data-envers/src/test/java/org/springframework/data/envers/sample/AbstractEntity.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
*/
1616
package org.springframework.data.envers.sample;
1717

18-
import lombok.EqualsAndHashCode;
19-
2018
import jakarta.persistence.GeneratedValue;
2119
import jakarta.persistence.Id;
2220
import jakarta.persistence.MappedSuperclass;
2321

2422
@MappedSuperclass
25-
@EqualsAndHashCode
2623
abstract class AbstractEntity {
2724

2825
public @Id @GeneratedValue Long id;
26+
2927
}

spring-data-envers/src/test/java/org/springframework/data/envers/sample/Country.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
import jakarta.persistence.Entity;
1919

20-
import lombok.ToString;
21-
import org.hibernate.envers.Audited;
22-
2320
import java.time.Instant;
2421

22+
import org.hibernate.envers.Audited;
23+
2524
/**
2625
* Sample domain class.
2726
*
@@ -31,12 +30,15 @@
3130
*/
3231
@Audited
3332
@Entity
34-
@ToString
3533
public class Country extends AbstractEntity {
3634

3735
public String code;
3836

3937
public Instant timestamp;
4038

4139
public String name;
40+
41+
public String toString() {
42+
return "Country(code=" + this.code + ", timestamp=" + this.timestamp + ", name=" + this.name + ")";
43+
}
4244
}

spring-data-envers/src/test/java/org/springframework/data/envers/sample/License.java

+21-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
*/
1616
package org.springframework.data.envers.sample;
1717

18-
import java.util.Set;
19-
2018
import jakarta.persistence.Entity;
2119
import jakarta.persistence.ManyToMany;
2220
import jakarta.persistence.Version;
2321

22+
import java.util.Objects;
23+
import java.util.Set;
24+
2425
import org.hibernate.envers.Audited;
2526

2627
/**
@@ -32,10 +33,24 @@
3233
@Entity
3334
public class License extends AbstractEntity {
3435

35-
@Version
36-
public Integer version;
36+
@Version public Integer version;
3737

3838
public String name;
39-
@ManyToMany
40-
public Set<Country> laender;
39+
@ManyToMany public Set<Country> laender;
40+
41+
@Override
42+
public boolean equals(Object o) {
43+
44+
if (this == o)
45+
return true;
46+
if (o == null || getClass() != o.getClass())
47+
return false;
48+
License license = (License) o;
49+
return Objects.equals(version, license.version) && Objects.equals(name, license.name);
50+
}
51+
52+
@Override
53+
public int hashCode() {
54+
return Objects.hash(version, name);
55+
}
4156
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AbstractMappedType.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package org.springframework.data.jpa.domain.sample;
1717

18-
import lombok.Getter;
19-
2018
import jakarta.persistence.GeneratedValue;
2119
import jakarta.persistence.Id;
2220
import jakarta.persistence.MappedSuperclass;
@@ -29,7 +27,8 @@
2927
@MappedSuperclass
3028
public abstract class AbstractMappedType {
3129

32-
@Id @GeneratedValue @Getter Long id;
30+
@Id
31+
@GeneratedValue Long id;
3332
@Version Long version;
3433
private String attribute1;
3534

@@ -38,4 +37,8 @@ public abstract class AbstractMappedType {
3837
AbstractMappedType(String attribute1) {
3938
this.attribute1 = attribute1;
4039
}
40+
41+
public Long getId() {
42+
return this.id;
43+
}
4144
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/EmployeeWithName.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,43 @@
1818
import jakarta.persistence.Entity;
1919
import jakarta.persistence.GeneratedValue;
2020
import jakarta.persistence.Id;
21-
import lombok.AccessLevel;
22-
import lombok.Data;
23-
import lombok.NoArgsConstructor;
2421

2522
/**
2623
* @author Greg Turnquist
2724
*/
2825
@Entity
29-
@NoArgsConstructor(access = AccessLevel.PROTECTED)
30-
@Data
3126
public class EmployeeWithName {
3227

3328
@Id
34-
@GeneratedValue private Integer id;
29+
@GeneratedValue //
30+
private Integer id;
3531
private String name;
3632

3733
public EmployeeWithName(String name) {
3834

3935
this();
4036
this.name = name;
4137
}
38+
39+
protected EmployeeWithName() {}
40+
41+
public Integer getId() {
42+
return this.id;
43+
}
44+
45+
public String getName() {
46+
return this.name;
47+
}
48+
49+
public void setId(Integer id) {
50+
this.id = id;
51+
}
52+
53+
public void setName(String name) {
54+
this.name = name;
55+
}
56+
57+
public String toString() {
58+
return "EmployeeWithName(id=" + this.getId() + ", name=" + this.getName() + ")";
59+
}
4260
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Item.java

+27-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import jakarta.persistence.IdClass;
2222
import jakarta.persistence.JoinColumn;
2323
import jakarta.persistence.Table;
24-
import lombok.EqualsAndHashCode;
25-
import lombok.ToString;
24+
25+
import java.util.Objects;
2626

2727
/**
2828
* @author Mark Paluch
@@ -32,13 +32,13 @@
3232
@Entity
3333
@Table
3434
@IdClass(ItemId.class)
35-
@EqualsAndHashCode
36-
@ToString
3735
public class Item {
3836

39-
@Id @Column(columnDefinition = "INT") private Integer id;
37+
@Id
38+
@Column(columnDefinition = "INT") private Integer id;
4039

41-
@Id @JoinColumn(name = "manufacturer_id", columnDefinition = "INT") private Integer manufacturerId;
40+
@Id
41+
@JoinColumn(name = "manufacturer_id", columnDefinition = "INT") private Integer manufacturerId;
4242

4343
private String name;
4444

@@ -72,4 +72,25 @@ public void setName(String name) {
7272
this.name = name;
7373
}
7474

75+
@Override
76+
public boolean equals(Object o) {
77+
78+
if (this == o)
79+
return true;
80+
if (o == null || getClass() != o.getClass())
81+
return false;
82+
Item item = (Item) o;
83+
return Objects.equals(id, item.id) && Objects.equals(manufacturerId, item.manufacturerId)
84+
&& Objects.equals(name, item.name);
85+
}
86+
87+
@Override
88+
public int hashCode() {
89+
return Objects.hash(id, manufacturerId, name);
90+
}
91+
92+
public String toString() {
93+
return "Item(id=" + this.getId() + ", manufacturerId=" + this.getManufacturerId() + ", name=" + this.getName()
94+
+ ")";
95+
}
7596
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/SampleWithIdClassIncludingEntity.java

+63-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package org.springframework.data.jpa.domain.sample;
22

3-
import lombok.Data;
4-
5-
import java.io.Serializable;
6-
73
import jakarta.persistence.Entity;
84
import jakarta.persistence.Id;
95
import jakarta.persistence.IdClass;
106
import jakarta.persistence.ManyToOne;
117

8+
import java.io.Serializable;
9+
1210
/**
1311
* Sample class for integration testing
1412
* {@link org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation}.
@@ -17,24 +15,81 @@
1715
*/
1816
@Entity
1917
@IdClass(SampleWithIdClassIncludingEntity.SampleWithIdClassPK.class)
20-
@Data
2118
public class SampleWithIdClassIncludingEntity {
2219

2320
@Id Long first;
24-
@ManyToOne @Id OtherEntity second;
21+
@ManyToOne
22+
@Id OtherEntity second;
23+
24+
public SampleWithIdClassIncludingEntity() {}
25+
26+
public Long getFirst() {
27+
return this.first;
28+
}
29+
30+
public OtherEntity getSecond() {
31+
return this.second;
32+
}
33+
34+
public void setFirst(Long first) {
35+
this.first = first;
36+
}
37+
38+
public void setSecond(OtherEntity second) {
39+
this.second = second;
40+
}
41+
42+
public String toString() {
43+
return "SampleWithIdClassIncludingEntity(first=" + this.getFirst() + ", second=" + this.getSecond() + ")";
44+
}
2545

26-
@Data
2746
@SuppressWarnings("serial")
2847
public static class SampleWithIdClassPK implements Serializable {
2948

3049
Long first;
3150
Long second;
51+
52+
public SampleWithIdClassPK() {}
53+
54+
public Long getFirst() {
55+
return this.first;
56+
}
57+
58+
public Long getSecond() {
59+
return this.second;
60+
}
61+
62+
public void setFirst(Long first) {
63+
this.first = first;
64+
}
65+
66+
public void setSecond(Long second) {
67+
this.second = second;
68+
}
69+
70+
public String toString() {
71+
return "SampleWithIdClassIncludingEntity.SampleWithIdClassPK(first=" + this.getFirst() + ", second="
72+
+ this.getSecond() + ")";
73+
}
3274
}
3375

3476
@Entity
35-
@Data
3677
public static class OtherEntity {
3778
@Id Long otherId;
79+
80+
public OtherEntity() {}
81+
82+
public Long getOtherId() {
83+
return this.otherId;
84+
}
85+
86+
public void setOtherId(Long otherId) {
87+
this.otherId = otherId;
88+
}
89+
90+
public String toString() {
91+
return "SampleWithIdClassIncludingEntity.OtherEntity(otherId=" + this.getOtherId() + ")";
92+
}
3893
}
3994

4095
/**

0 commit comments

Comments
 (0)