File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 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 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 1818import jakarta .persistence .CascadeType ;
1919import jakarta .persistence .Entity ;
2020import jakarta .persistence .FetchType ;
21- import jakarta .persistence .GeneratedValue ;
2221import jakarta .persistence .Id ;
2322import jakarta .persistence .ManyToOne ;
2423import jakarta .persistence .OneToMany ;
3029
3130/**
3231 * @author Oliver Gierke
32+ * @author Mark Paluch
3333 */
3434@ Entity
3535@ Table (name = "ORDERS" )
3636public class Order {
3737
38- @ Id @ GeneratedValue //
39- private Long id ;
38+ @ Id
39+ @ SequenceGenerator private Long id ;
4040@ ManyToOne (fetch = FetchType .LAZY ) //
4141private Person creator ;
4242@ 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