HHH-16952 Disable enhancement expectation for attributes annotated with @Embedded when the type is not annotated with @Embeddable
This commit is contained in:
parent
4ba39b70c7
commit
a8a4ff2af0
|
@ -69,7 +69,7 @@ class ByteBuddyEnhancementContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompositeField(AnnotatedFieldDescription field) {
|
public boolean isCompositeField(AnnotatedFieldDescription field) {
|
||||||
return isCompositeClass( field.getType().asErasure() ) || field.hasAnnotation( Embedded.class );
|
return isCompositeClass( field.getType().asErasure() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnnotatedFieldDescription[] order(AnnotatedFieldDescription[] persistentFields) {
|
public AnnotatedFieldDescription[] order(AnnotatedFieldDescription[] persistentFields) {
|
||||||
|
|
|
@ -13,30 +13,46 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
|
import jakarta.persistence.Embedded;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
@JiraKey( "HHH-16774" )
|
@JiraKey( "HHH-16774" )
|
||||||
|
@JiraKey( "HHH-16952" )
|
||||||
@RunWith( BytecodeEnhancerRunner.class )
|
@RunWith( BytecodeEnhancerRunner.class )
|
||||||
public class DirtyTrackingEmbeddableTest {
|
public class DirtyTrackingEmbeddableTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
SimpleEntity entity = new SimpleEntity();
|
SimpleEntity entity = new SimpleEntity();
|
||||||
Address address = new Address();
|
Address1 address1 = new Address1();
|
||||||
entity.address = address;
|
entity.address1 = address1;
|
||||||
|
Address2 address2 = new Address2();
|
||||||
|
entity.address2 = address2;
|
||||||
EnhancerTestUtils.clearDirtyTracking( entity );
|
EnhancerTestUtils.clearDirtyTracking( entity );
|
||||||
|
|
||||||
// testing composite object
|
// testing composite object
|
||||||
address.city = "Arendal";
|
address1.city = "Arendal";
|
||||||
EnhancerTestUtils.checkDirtyTracking( entity, "address" );
|
address2.city = "Arendal";
|
||||||
|
// In 6.2, we can't change the SPI to make HHH-16952 possible,
|
||||||
|
// but we make sure to at least don't fail with an exception
|
||||||
|
EnhancerTestUtils.checkDirtyTracking( entity, "address1" );
|
||||||
EnhancerTestUtils.clearDirtyTracking( entity );
|
EnhancerTestUtils.clearDirtyTracking( entity );
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- //
|
// --- //
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
private static class Address {
|
private static class Address1 {
|
||||||
|
String street1;
|
||||||
|
String street2;
|
||||||
|
String city;
|
||||||
|
String state;
|
||||||
|
String zip;
|
||||||
|
String phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Address2 {
|
||||||
String street1;
|
String street1;
|
||||||
String street2;
|
String street2;
|
||||||
String city;
|
String city;
|
||||||
|
@ -53,7 +69,9 @@ public class DirtyTrackingEmbeddableTest {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
Address address;
|
Address1 address1;
|
||||||
|
@Embedded
|
||||||
|
Address2 address2;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue