Skip to content

Commit 10c6a3b

Browse files
mp911deodrotbohm
authored andcommitted
Upgrade to Hibernate 7.0.0.Beta1.
Closes #2444
1 parent 755ecfe commit 10c6a3b

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<springdata.mongodb>5.0.0-SNAPSHOT</springdata.mongodb>
3434
<springdata.keyvalue>4.0.0-SNAPSHOT</springdata.keyvalue>
3535

36-
<hibernate.version>6.5.2.Final</hibernate.version>
36+
<hibernate.version>7.0.0.Beta1</hibernate.version>
3737
</properties>
3838

3939
<developers>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.springframework.data.rest.webmvc.jpa;
2+
3+
import org.hibernate.id.enhanced.SequenceStyleGenerator;
4+
5+
/**
6+
* Extension to {@link SequenceStyleGenerator} to allow assigned identifiers.
7+
*
8+
* @author Mark Paluch
9+
* @see <a href=
10+
* "https://discourse.hibernate.org/t/manually-setting-the-identifier-results-in-object-optimistic-locking-failure-exception/10743/6">Manually
11+
* setting the identifier results in object optimistic locking failure exception</a>
12+
* @see <a href="https://hibernate.atlassian.net/browse/HHH-17472">HHH-17472</a>
13+
*/
14+
public class AssignableSequenceStyleGenerator extends SequenceStyleGenerator {
15+
16+
@Override
17+
public boolean allowAssignedIdentifiers() {
18+
return true;
19+
}
20+
}

spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Order.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import jakarta.persistence.CascadeType;
1919
import jakarta.persistence.Entity;
2020
import jakarta.persistence.FetchType;
21-
import jakarta.persistence.GeneratedValue;
2221
import jakarta.persistence.Id;
2322
import jakarta.persistence.ManyToOne;
2423
import jakarta.persistence.OneToMany;
@@ -30,13 +29,14 @@
3029

3130
/**
3231
* @author Oliver Gierke
32+
* @author Mark Paluch
3333
*/
3434
@Entity
3535
@Table(name = "ORDERS")
3636
public class Order {
3737

38-
@Id @GeneratedValue //
39-
private Long id;
38+
@Id
39+
@SequenceGenerator private Long id;
4040
@ManyToOne(fetch = FetchType.LAZY) //
4141
private Person creator;
4242
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) //
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.springframework.data.rest.webmvc.jpa;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
import org.hibernate.annotations.IdGeneratorType;
9+
10+
/**
11+
* Variant of {@link jakarta.persistence.GeneratedValue} using Hibernate-specific generators.
12+
*
13+
* @see <a href=
14+
* "https://discourse.hibernate.org/t/manually-setting-the-identifier-results-in-object-optimistic-locking-failure-exception/10743/6">Manually
15+
* setting the identifier results in object optimistic locking failure exception</a>
16+
* @see <a href="https://hibernate.atlassian.net/browse/HHH-17472">HHH-17472</a>
17+
*/
18+
@IdGeneratorType(AssignableSequenceStyleGenerator.class)
19+
@Retention(RetentionPolicy.RUNTIME)
20+
@Target({ ElementType.METHOD, ElementType.FIELD })
21+
public @interface SequenceGenerator {
22+
}

0 commit comments

Comments
 (0)