Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-16542 (
https://hibernate.atlassian.net/browse/HHH-16542?atlOrigin=eyJpIjoiZTJmZG...
)
Re: (Jakarta EE 10 Platform TCK)
jpa/core/entitytest/cascadeall/oneXone/cascadeAll1X1Test10 test regression (
https://hibernate.atlassian.net/browse/HHH-16542?atlOrigin=eyJpIjoiZTJmZG...
)
this is the test I used
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
@RunWith(BytecodeEnhancerRunner.class)
@EnhancementOptions(inlineDirtyChecking = true, lazyLoading = true, extendedEnhancement =
true)
public class TestIt extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[]{
A.class,
B.class
};
}
@Test
public void testIt(){
inTransaction(
entityManager -> {
}
);
}
@Entity
@Table(name = "AEJB_1X1_BI_BTOB")
public class A implements java.io.Serializable {
// ===========================================================
// instance variables
@Id
protected String id;
@Basic
protected String name;
@Basic
protected int value;
// ===========================================================
// constructors
public A() {
}
public A(String id, String name, int value) {
this.id = id;
this.name = name;
this.value = value;
}
public A(String id, String name, int value, B b1) {
this.id = id;
this.name = name;
this.value = value;
this.b1 = b1;
}
// ===========================================================
// relationship fields
@OneToOne(targetEntity = B.class, mappedBy = "a1", orphanRemoval = true)
protected B b1;
// =======================================================================
// Business methods for test cases
public B getB1() {
return b1;
}
public boolean isB1() {
return getB1() != null;
}
public B getB1Info() {
if (isB1()) {
B b1 = getB1();
return b1;
} else
return null;
}
public String getAId() {
return id;
}
public String getAName() {
return name;
}
public int getAValue() {
return value;
}
}
@Entity
@Table(name = "BEJB_1X1_BI_BTOB")
public class B implements java.io.Serializable {
// ===========================================================
// instance variables
@Id
protected String id;
@Basic
protected String name;
@Basic
protected int value;
// ===========================================================
// relationship fields
@OneToOne(targetEntity = A.class, cascade = CascadeType.ALL, optional = true,
orphanRemoval = true)
@JoinColumn(name = "FK_FOR_AEJB_1X1_BI_BTOB")
protected A a1;
// ===========================================================
// constructors
public B() {
}
public B(String id, String name, int value) {
this.id = id;
this.name = name;
this.value = value;
}
public B(String id, String name, int value, A a1) {
this.id = id;
this.name = name;
this.value = value;
this.a1 = a1;
}
// ==========================================================
// Business Methods for Test Cases
public A getA1() {
return a1;
}
public void setA1(A a1) {
this.a1 = a1;
}
public boolean isA() {
return getA1() != null;
}
public A getA1Info() {
if (isA()) {
A a1 = getA1();
return a1;
} else
return null;
}
public String getBId() {
return id;
}
public String getBName() {
return name;
}
public void setBName(String name) {
this.name = name;
}
public int getBValue() {
return value;
}
}
}
but as I said I think the exception is the expected behaviour with bytecode enhancement,
see
https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m...
(
https://hibernate.atlassian.net/browse/HHH-16542#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16542#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100224- sha1:4684446 )