HHH-14975 - Allow use of auto-applied AttributeConverter as native-query result or parameter
This commit is contained in:
parent
38fa2aef75
commit
fcda293c5e
|
@ -22,9 +22,13 @@ import jakarta.persistence.Table;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -63,6 +67,7 @@ public class QueryTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@JiraKey( "HHH-13082" )
|
||||
public void testNativeQueryResult() {
|
||||
inTransaction( (session) -> {
|
||||
final NativeQueryImplementor<Object[]> query = session.createNativeQuery( "select id, salary from EMP", "emp_id_salary" );
|
||||
|
@ -76,6 +81,23 @@ public class QueryTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-14975", message = "Not yet implemented" )
|
||||
@NotImplementedYet
|
||||
@JiraKey( "HHH-14975" )
|
||||
public void testAutoAppliedConverterAsNativeQueryResult() {
|
||||
inTransaction( (session) -> {
|
||||
final NativeQueryImplementor<Object[]> query = session.createNativeQuery( "select id, salary from EMP", "emp_id_salary2" );
|
||||
|
||||
final List<Object[]> results = query.list();
|
||||
assertThat( results ).hasSize( 1 );
|
||||
|
||||
final Object[] values = results.get( 0 );
|
||||
assertThat( values[0] ).isEqualTo( 1 );
|
||||
assertThat( values[1] ).isEqualTo( SALARY );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] { Employee.class, SalaryConverter.class };
|
||||
|
@ -108,6 +130,13 @@ public class QueryTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
@ColumnResult( name = "salary", type = SalaryConverter.class )
|
||||
}
|
||||
)
|
||||
@SqlResultSetMapping(
|
||||
name = "emp_id_salary2",
|
||||
columns = {
|
||||
@ColumnResult( name = "id" ),
|
||||
@ColumnResult( name = "salary", type = Float.class )
|
||||
}
|
||||
)
|
||||
public static class Employee {
|
||||
@Id
|
||||
public Integer id;
|
||||
|
|
Loading…
Reference in New Issue