File tree 4 files changed +46
-4
lines changed
spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa
4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 33
33
<springdata .mongodb>5.0.0-SNAPSHOT</springdata .mongodb>
34
34
<springdata .keyvalue>4.0.0-SNAPSHOT</springdata .keyvalue>
35
35
36
- <hibernate .version>6.5.2.Final </hibernate .version>
36
+ <hibernate .version>7.0.0.Beta1 </hibernate .version>
37
37
</properties >
38
38
39
39
<developers >
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 18
18
import jakarta .persistence .CascadeType ;
19
19
import jakarta .persistence .Entity ;
20
20
import jakarta .persistence .FetchType ;
21
- import jakarta .persistence .GeneratedValue ;
22
21
import jakarta .persistence .Id ;
23
22
import jakarta .persistence .ManyToOne ;
24
23
import jakarta .persistence .OneToMany ;
30
29
31
30
/**
32
31
* @author Oliver Gierke
32
+ * @author Mark Paluch
33
33
*/
34
34
@ Entity
35
35
@ Table (name = "ORDERS" )
36
36
public class Order {
37
37
38
- @ Id @ GeneratedValue //
39
- private Long id ;
38
+ @ Id
39
+ @ SequenceGenerator private Long id ;
40
40
@ ManyToOne (fetch = FetchType .LAZY ) //
41
41
private Person creator ;
42
42
@ OneToMany (cascade = CascadeType .ALL , orphanRemoval = true ) //
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments