HHH-17885 Test for same named attribute of different Embedded uses same selection expression

This commit is contained in:
Christian Beikov 2024-04-02 16:27:33 +02:00
parent d18d925e10
commit 1fe26bc7f4
4 changed files with 21 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import java.io.Serializable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Embeddable; import jakarta.persistence.Embeddable;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.Formula;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -23,4 +24,7 @@ public class Address implements Serializable {
Country country; Country country;
@ManyToOne @ManyToOne
AddressType type; AddressType type;
@Formula("1")
Integer formula;
} }

View File

@ -0,0 +1,11 @@
package org.hibernate.orm.test.bootstrap.binding.annotations.embedded;
import jakarta.persistence.Embeddable;
import org.hibernate.annotations.Formula;
@Embeddable
public class AddressBis {
@Formula("2")
Integer formula;
}

View File

@ -100,10 +100,13 @@ public class EmbeddedTest {
assertNotNull( p ); assertNotNull( p );
assertNotNull( p.address ); assertNotNull( p.address );
assertEquals( "Springfield", p.address.city ); assertEquals( "Springfield", p.address.city );
assertEquals( (Integer) 1, p.address.formula );
assertNotNull( p.address.country ); assertNotNull( p.address.country );
assertEquals( "DM", p.address.country.getIso2() ); assertEquals( "DM", p.address.country.getIso2() );
assertNotNull( p.bornIn ); assertNotNull( p.bornIn );
assertEquals( "US", p.bornIn.getIso2() ); assertEquals( "US", p.bornIn.getIso2() );
assertEquals( (Integer) 2, p.addressBis.formula );
} ); } );
} }

View File

@ -33,6 +33,9 @@ public class Person implements Serializable {
@Embedded @Embedded
Address address; Address address;
@Embedded
AddressBis addressBis;
@Embedded @Embedded
@AttributeOverrides( { @AttributeOverrides( {
@AttributeOverride(name = "iso2", column = @Column(name = "bornIso2")), @AttributeOverride(name = "iso2", column = @Column(name = "bornIso2")),