[JIRA] (HHH-16542) (Jakarta EE 10 Platform TCK) jpa/core/entitytest/cascadeall/oneXone/cascadeAll1X1Test10 test regression
by Scott Marlow (JIRA)
Scott Marlow ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16542 ( https://hibernate.atlassian.net/browse/HHH-16542?atlOrigin=eyJpIjoiNDVlM2... )
Re: (Jakarta EE 10 Platform TCK) jpa/core/entitytest/cascadeall/oneXone/cascadeAll1X1Test10 test regression ( https://hibernate.atlassian.net/browse/HHH-16542?atlOrigin=eyJpIjoiNDVlM2... )
private static void checkGetAndIsVariants(
Class containerClass, String propertyName, Method getMethod, Method isMethod) {
// Check the return types. If they are the same, its ok. If they are different // we are in a situation where we could not reasonably know which to use.
if ( !isMethod.getReturnType().equals( getMethod.getReturnType() ) ) {
throw new MappingException(
String.format(
Locale.ROOT, "In trying to locate getter for property [%s], Class [%s] defined " +
"both a `get` [%s] and `is` [%s] variant", propertyName, containerClass.getName(), getMethod.toString(), isMethod.toString()
)
); }
}
Mentioned ReflectHelper code is ^ and error is:
org.hibernate.MappingException: In trying to locate getter for property [b1] , Class [com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone.A] defined both a get [public com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone.B com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone.A.getB1()] and is [public boolean com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone.A.isB1()] variant
The offending TCK source code is:
@OneToOne(targetEntity = com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone.B.class, mappedBy = "a1", orphanRemoval = true)
protected B b1;
public B getB1()
{ return b1; }
public boolean isB1()
{ TestUtil.logTrace("isB1"); if (getB1() != null) TestUtil.logTrace("Relationship to B is not null..."); else TestUtil.logTrace("Relationship for B is null ..."); return getB1() != null; }
Apologies for pasting all of the above but it helps me to see it all together as one comment. 🙂
From the above pasted code + error, I think the test would pass if both methods returned either B or boolean but is that only a Hibernate requirement or is that also Persistence Specification requirement?
Could ReflectHelper be enhanced to handle ^ differently in JPA_COMPLIANCE mode?
( 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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100224- sha1:4684446 )
2 years, 7 months
[JIRA] (HHH-16542) (Jakarta EE 10 Platform TCK) jpa/core/entitytest/cascadeall/oneXone/cascadeAll1X1Test10 test regression
by Andrea Boriero (JIRA)
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100224- sha1:4684446 )
2 years, 7 months