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) {
|
||||
return isCompositeClass( field.getType().asErasure() ) || field.hasAnnotation( Embedded.class );
|
||||
return isCompositeClass( field.getType().asErasure() );
|
||||
}
|
||||
|
||||
public AnnotatedFieldDescription[] order(AnnotatedFieldDescription[] persistentFields) {
|
||||
|
|
|
@ -13,30 +13,46 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@JiraKey( "HHH-16774" )
|
||||
@JiraKey( "HHH-16952" )
|
||||
@RunWith( BytecodeEnhancerRunner.class )
|
||||
public class DirtyTrackingEmbeddableTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SimpleEntity entity = new SimpleEntity();
|
||||
Address address = new Address();
|
||||
entity.address = address;
|
||||
Address1 address1 = new Address1();
|
||||
entity.address1 = address1;
|
||||
Address2 address2 = new Address2();
|
||||
entity.address2 = address2;
|
||||
EnhancerTestUtils.clearDirtyTracking( entity );
|
||||
|
||||
// testing composite object
|
||||
address.city = "Arendal";
|
||||
EnhancerTestUtils.checkDirtyTracking( entity, "address" );
|
||||
address1.city = "Arendal";
|
||||
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 );
|
||||
}
|
||||
|
||||
// --- //
|
||||
|
||||
@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 street2;
|
||||
String city;
|
||||
|
@ -53,7 +69,9 @@ public class DirtyTrackingEmbeddableTest {
|
|||
|
||||
String name;
|
||||
|
||||
Address address;
|
||||
Address1 address1;
|
||||
@Embedded
|
||||
Address2 address2;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue