HHH-16833 Add test for issue
This commit is contained in:
parent
fef04bc62e
commit
5d85db9211
|
@ -0,0 +1,73 @@
|
|||
package org.hibernate.orm.test.version;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Version;
|
||||
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
VersionedBidirectionalOneToOneMergeTest.TestEntity.class,
|
||||
VersionedBidirectionalOneToOneMergeTest.AnotherTestEntity.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
@JiraKey("HHH-16833")
|
||||
public class VersionedBidirectionalOneToOneMergeTest {
|
||||
|
||||
@Test
|
||||
public void testMerge(SessionFactoryScope scope) {
|
||||
AnotherTestEntity anotherTestEntity = new AnotherTestEntity();
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.persist( anotherTestEntity );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
TestEntity testEntity = new TestEntity( anotherTestEntity );
|
||||
session.persist( testEntity );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity(name = "TestEntity")
|
||||
public static class TestEntity {
|
||||
@Id
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "OTHER_ENTITY_ID")
|
||||
AnotherTestEntity anotherTestEntity;
|
||||
|
||||
public TestEntity() {
|
||||
}
|
||||
|
||||
public TestEntity(AnotherTestEntity anotherTestEntity) {
|
||||
this.anotherTestEntity = anotherTestEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "AnotherTestEntity")
|
||||
public static class AnotherTestEntity {
|
||||
@Id
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
@OneToOne(mappedBy = "anotherTestEntity")
|
||||
TestEntity testEntity;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue