Phil Haeusler (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15658 (
https://hibernate.atlassian.net/browse/HHH-15658?atlOrigin=eyJpIjoiNGU0OG...
)
Re: Embeddable with more fields than the parent fails with Index out of Bounds (
https://hibernate.atlassian.net/browse/HHH-15658?atlOrigin=eyJpIjoiNGU0OG...
)
Andrea, attached is a simple reproduction of this issue
@DomainModel(
annotatedClasses = HHH15658Test.Contact.class
)
public class HHH15658Test extends BaseCoreFunctionalTestCase {
@Override
protected Class [] getAnnotatedClasses() {
return new Class [] {
Contact.class
};
}
// Add in any settings that are specific to your test. See
resources/hibernate.properties for the defaults.
@Override
protected void configure(Configuration configuration) {
super.configure( configuration );
configuration.setProperty( AvailableSettings.SHOW_SQL, Boolean.TRUE.toString() );
configuration.setProperty( AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString() );
//configuration.setProperty( AvailableSettings.GENERATE_STATISTICS, " true "
);
}
@Test
public void hhh15658Test() throws Exception {
// BaseCoreFunctionalTestCase automatically creates the SessionFactory and provides the
Session.
Session s = openSession();
Transaction tx = s.beginTransaction();
final String sql = """
select {c.*}
from contact c
""";
var contacts = s.createNativeQuery(sql, Contact.class, "c" ).list();
tx.commit();
s.close();
}
@Entity(name = "Contact" )
public static class Contact
{
@Id
private Long id;
private Address address;
}
@Embeddable
public static class Address
{
private String city;
private String state;
private String country;
private String postcode;
}
}
Exception is
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at
org.hibernate.persister.entity.SingleTableEntityPersister.getSubclassPropertyTableNumber(SingleTableEntityPersister.java:594)
at
org.hibernate.persister.entity.AbstractEntityPersister.lambda$selectFragment$6(AbstractEntityPersister.java:1881)
at
org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:118)
at
org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32)
at
org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl.<init>(EmbeddableFetchImpl.java:75)
at
org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping.generateFetch(EmbeddedAttributeMapping.java:238)
at
org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:105)
at
org.hibernate.persister.entity.AbstractEntityPersister.lambda$selectFragment$6(AbstractEntityPersister.java:1910)
at
org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:118)
at
org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32)
at
org.hibernate.sql.results.graph.entity.AbstractEntityResultGraphNode.afterInitialize(AbstractEntityResultGraphNode.java:100)
at
org.hibernate.persister.entity.AbstractEntityPersister.createDomainResult(AbstractEntityPersister.java:1289)
at
org.hibernate.persister.entity.AbstractEntityPersister.selectFragment(AbstractEntityPersister.java:1943)
at
org.hibernate.query.sql.internal.SQLQueryParser.resolveProperties(SQLQueryParser.java:236)
at
org.hibernate.query.sql.internal.SQLQueryParser.substituteBrackets(SQLQueryParser.java:159)
at org.hibernate.query.sql.internal.SQLQueryParser.process(SQLQueryParser.java:63)
at
org.hibernate.query.sql.internal.NativeSelectQueryPlanImpl.<init>(NativeSelectQueryPlanImpl.java:53)
at
org.hibernate.engine.query.internal.NativeQueryInterpreterStandardImpl.createQueryPlan(NativeQueryInterpreterStandardImpl.java:39)
at
org.hibernate.query.sql.internal.NativeQueryImpl.createQueryPlan(NativeQueryImpl.java:643)
at
org.hibernate.query.sql.internal.NativeQueryImpl.lambda$resolveSelectQueryPlan$7(NativeQueryImpl.java:604)
at
org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveSelectQueryPlan(QueryInterpretationCacheStandardImpl.java:83)
at
org.hibernate.query.sql.internal.NativeQueryImpl.resolveSelectQueryPlan(NativeQueryImpl.java:602)
at org.hibernate.query.sql.internal.NativeQueryImpl.doList(NativeQueryImpl.java:596)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363)
at org.hibernate.bugs.HHH15658Test.hhh15658Test(HHH15658Test.java:74)
(
https://hibernate.atlassian.net/browse/HHH-15658#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15658#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100210- sha1:4f8bc0d )