1414import jakarta .persistence .Table ;
1515import jakarta .persistence .Tuple ;
1616import jakarta .persistence .Version ;
17+ import org .hibernate .Hibernate ;
1718import org .hibernate .InstantiationException ;
1819import org .hibernate .testing .orm .junit .DomainModel ;
1920import org .hibernate .testing .orm .junit .JiraKey ;
2930
3031import static org .assertj .core .api .Assertions .assertThat ;
3132import static org .junit .jupiter .api .Assertions .assertThrows ;
33+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3234
3335@ DomainModel (
3436 annotatedClasses = {
3739 }
3840)
3941@ SessionFactory
40- @ JiraKey ("HHH-19868" )
4142public class SelectWithWrongResultTypeTest {
4243
4344 @ BeforeEach
@@ -56,6 +57,7 @@ public void setUp(SessionFactoryScope scope) {
5657 }
5758
5859 @ AfterEach
60+ @ JiraKey ("HHH-19868" )
5961 public void tearDown (SessionFactoryScope scope ) {
6062 scope .getSessionFactory ().getSchemaManager ().truncateMappedObjects ();
6163 }
@@ -84,6 +86,29 @@ void testSelectWithWrongResultType(SessionFactoryScope scope) {
8486 .getResultList ();
8587 assertThat ( resultList ).hasSize ( 1 );
8688 } ) );
89+
90+ }
91+
92+ @ Test
93+ @ JiraKey ("HHH-19874" )
94+ void testSelectWithArrayReturnType (SessionFactoryScope scope ) {
95+ scope .inTransaction ( session -> {
96+ List <Node > list = session .createSelectionQuery ( "from Node order by id" , Node .class ).getResultList ();
97+ assertThat ( list ).hasSize ( 2 );
98+ assertThat ( Hibernate .isInitialized ( list .get ( 0 ).elements ) ).isTrue ();
99+ assertThat ( list .get ( 0 ).elements ).hasSize ( 3 );
100+ assertThat ( list .get ( 1 ).elements ).isEmpty ();
101+ } );
102+
103+ scope .inTransaction ( session -> {
104+ List <Object []> list = session .createSelectionQuery (
105+ "select distinct n, e from Node n join n.elements e order by n.id" , Object [].class )
106+ .getResultList ();
107+ assertThat ( list ).hasSize ( 3 );
108+ Object [] tup = list .get ( 0 );
109+ assertTrue ( Hibernate .isInitialized ( ((Node ) tup [0 ]).elements ) );
110+ assertThat ( ((Node ) tup [0 ]).elements ).hasSize ( 3 );
111+ } );
87112 }
88113
89114 @ Test
0 commit comments