Skip to content

Commit 62836b5

Browse files
committed
HHH-17885 Test for same named attribute of different Embedded uses same selection expression
1 parent 50ff8dc commit 62836b5

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Address.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import jakarta.persistence.Column;
1212
import jakarta.persistence.Embeddable;
1313
import jakarta.persistence.ManyToOne;
14+
import org.hibernate.annotations.Formula;
1415

1516
/**
1617
* @author Emmanuel Bernard
@@ -23,4 +24,7 @@ public class Address implements Serializable {
2324
Country country;
2425
@ManyToOne
2526
AddressType type;
27+
28+
@Formula("1")
29+
Integer formula;
2630
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.hibernate.orm.test.bootstrap.binding.annotations.embedded;
2+
3+
import jakarta.persistence.Embeddable;
4+
import org.hibernate.annotations.Formula;
5+
6+
@Embeddable
7+
public class AddressBis {
8+
9+
@Formula("2")
10+
Integer formula;
11+
}

hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/EmbeddedTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ public void testSimple(SessionFactoryScope scope) {
100100
assertNotNull( p );
101101
assertNotNull( p.address );
102102
assertEquals( "Springfield", p.address.city );
103+
assertEquals( (Integer) 1, p.address.formula );
104+
103105
assertNotNull( p.address.country );
104106
assertEquals( "DM", p.address.country.getIso2() );
105107
assertNotNull( p.bornIn );
106108
assertEquals( "US", p.bornIn.getIso2() );
109+
assertEquals( (Integer) 2, p.addressBis.formula );
107110
} );
108111
}
109112

hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Person.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class Person implements Serializable {
3333
@Embedded
3434
Address address;
3535

36+
@Embedded
37+
AddressBis addressBis;
38+
3639
@Embedded
3740
@AttributeOverrides( {
3841
@AttributeOverride(name = "iso2", column = @Column(name = "bornIso2")),

0 commit comments

Comments
 (0)