File tree Expand file tree Collapse file tree 3 files changed +78
-0
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/unionsubclass/secondarytables Expand file tree Collapse file tree 3 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: LGPL-2.1-or-later
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .unionsubclass .secondarytables ;
6+
7+ import jakarta .persistence .Column ;
8+ import jakarta .persistence .Entity ;
9+ import jakarta .persistence .PrimaryKeyJoinColumn ;
10+ import jakarta .persistence .SecondaryTable ;
11+
12+ import java .time .ZonedDateTime ;
13+
14+ /**
15+ * @author Steve Ebersole
16+ */
17+ @ Entity
18+ @ SecondaryTable (
19+ name = "authorizations" ,
20+ pkJoinColumns = @ PrimaryKeyJoinColumn (name = "charge_auth_fk" , referencedColumnName = "id" )
21+ )
22+ public class CardPayment extends Payment {
23+ ZonedDateTime paymentMade ;
24+
25+ @ Column (table = "authorizations" )
26+ String authorizationCode ;
27+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: LGPL-2.1-or-later
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .unionsubclass .secondarytables ;
6+
7+ import jakarta .persistence .Entity ;
8+ import jakarta .persistence .Id ;
9+ import jakarta .persistence .Inheritance ;
10+ import jakarta .persistence .InheritanceType ;
11+
12+ /**
13+ * @author Steve Ebersole
14+ */
15+ @ Entity
16+ @ Inheritance (strategy = InheritanceType .TABLE_PER_CLASS )
17+ public abstract class Payment {
18+ @ Id
19+ private Integer id ;
20+ private String note ;
21+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: LGPL-2.1-or-later
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .unionsubclass .secondarytables ;
6+
7+ import org .hibernate .testing .orm .junit .DomainModel ;
8+ import org .hibernate .testing .orm .junit .FailureExpected ;
9+ import org .hibernate .testing .orm .junit .Jira ;
10+ import org .hibernate .testing .orm .junit .SessionFactory ;
11+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
12+ import org .junit .jupiter .api .Test ;
13+
14+ /**
15+ * @author Steve Ebersole
16+ */
17+ @ SuppressWarnings ("JUnitMalformedDeclaration" )
18+ @ DomainModel (annotatedClasses = {Payment .class , CardPayment .class })
19+ @ SessionFactory
20+ public class UnionSubclassWithSecondaryTableTests {
21+ @ Test
22+ @ FailureExpected
23+ @ Jira ("https://hibernate.atlassian.net/browse/HHH-12676" )
24+ void testIt (SessionFactoryScope sessions ) {
25+ sessions .inTransaction ( (session ) -> {
26+ session .createQuery ( "from CardPayment" ).getResultList ();
27+ session .createQuery ( "from Payment" ).getResultList ();
28+ } );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments