2
pom.xml
2
pom.xml
@@ -33,7 +33,7 @@
|
||||
<springdata.mongodb>5.0.0-SNAPSHOT</springdata.mongodb>
|
||||
<springdata.keyvalue>4.0.0-SNAPSHOT</springdata.keyvalue>
|
||||
|
||||
<hibernate.version>6.5.2.Final</hibernate.version>
|
||||
<hibernate.version>7.0.0.Beta1</hibernate.version>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springframework.data.rest.webmvc.jpa;
|
||||
|
||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||
|
||||
/**
|
||||
* Extension to {@link SequenceStyleGenerator} to allow assigned identifiers.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @see <a href=
|
||||
* "https://discourse.hibernate.org/t/manually-setting-the-identifier-results-in-object-optimistic-locking-failure-exception/10743/6">Manually
|
||||
* setting the identifier results in object optimistic locking failure exception</a>
|
||||
* @see <a href="https://hibernate.atlassian.net/browse/HHH-17472">HHH-17472</a>
|
||||
*/
|
||||
public class AssignableSequenceStyleGenerator extends SequenceStyleGenerator {
|
||||
|
||||
@Override
|
||||
public boolean allowAssignedIdentifiers() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.rest.webmvc.jpa;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
@@ -30,13 +29,14 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ORDERS")
|
||||
public class Order {
|
||||
|
||||
@Id @GeneratedValue //
|
||||
private Long id;
|
||||
@Id
|
||||
@SequenceGenerator private Long id;
|
||||
@ManyToOne(fetch = FetchType.LAZY) //
|
||||
private Person creator;
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) //
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.springframework.data.rest.webmvc.jpa;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hibernate.annotations.IdGeneratorType;
|
||||
|
||||
/**
|
||||
* Variant of {@link jakarta.persistence.GeneratedValue} using Hibernate-specific generators.
|
||||
*
|
||||
* @see <a href=
|
||||
* "https://discourse.hibernate.org/t/manually-setting-the-identifier-results-in-object-optimistic-locking-failure-exception/10743/6">Manually
|
||||
* setting the identifier results in object optimistic locking failure exception</a>
|
||||
* @see <a href="https://hibernate.atlassian.net/browse/HHH-17472">HHH-17472</a>
|
||||
*/
|
||||
@IdGeneratorType(AssignableSequenceStyleGenerator.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.FIELD })
|
||||
public @interface SequenceGenerator {
|
||||
}
|
||||
Reference in New Issue
Block a user