//imports, etc.
@Entity
@Table(name = "TSTRANS")
@SqlResultSetMappings(
{
@SqlResultSetMapping(name = TS_TRANS_EMP_STAT,
classes = {
@ConstructorResult(
targetClass = EmpStat.class,
columns = {
@ColumnResult(name = "EMPID", type = Long.class),
@ColumnResult(name = "CODE", type = String.class),
@ColumnResult(name = "TOTALCOUNT", type = Integer.class)
}
)
})
}
)
@NamedNativeQueries({
@NamedNativeQuery(name = "TsTrans.getStat", query = "select * from SP_TASK_STATS_EMP (:in_empid, :in_gidstr, :in_onlytodo)", resultSetMapping = TS_TRANS_EMP_STAT)
})
public class TsTrans extends TsTransCommon {
public static final String TSTRANS_BADGE = "TSTRANS_BADGE";
private static final long serialVersionUID = -3391028108003625153L;
public static final String TS_TRANS_EMP_STAT = "TsTrans.empStat";
public static final String TS_TRANS_SCHEDULE_STAT = "TsTrans.getScheduleStat";
public static final String TS_TRANS_FOLLOWUP = "TS_TRANS_FOLLOWUP";
}
Это объект.
// imports, etc.
public class EmpStat extends BaseStat {
private static final long serialVersionUID = -4410895509438727581L;
private Long mEmpid;
public EmpStat(Long aEmpid, String aCode, Integer aTotalcount) {
super(aCode, aTotalcount);
mEmpid = aEmpid;
}
public Long getEmpid() {
return mEmpid;
}
public void setEmpid(Long aEmpid) {
mEmpid = aEmpid;
}
}
Это необъектное pojo, тип возврата namedquery.
// imports, etc.
@Repository
public interface TsTransRepository extends TsTransCommonRepository<TsTrans> {
List<EmpStat> getStat(@Param("in_empid") Long aEmpid, @Param("in_gidstr") String aGidstr, @Param("in_onlytodo") Boolean aOnlytodo);
}
Это класс репозитория.
Я использую эту namednativequeries, чтобы возвращать не-сущности pojos из хранимых процедур. Он работает без исключения с Spring Boot 1.5.9. И на Spring Boot 2.0.0.M7. После перехода на 2.0.0.RELEASE началось следующее исключение.
org.hibernate.HibernateException: Got different size of tuples and aliases
at org.hibernate.jpa.spi.NativeQueryTupleTransformer$NativeTupleImpl.<init>(NativeQueryTupleTransformer.java:68) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.jpa.spi.NativeQueryTupleTransformer.transformTuple(NativeQueryTupleTransformer.java:28) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.hql.internal.HolderInstantiator.instantiate(HolderInstantiator.java:85) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.loader.custom.CustomLoader.getResultList(CustomLoader.java:430) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.loader.Loader.list(Loader.java:2502) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:335) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2161) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1016) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:152) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.query.Query.getResultList(Query.java:146) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:129) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:91) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:136) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:590) ~[spring-data-commons-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578) ~[spring-data-commons-2.0.5.RELEASE.jar:2.0.5.RELEASE]
Я пропустил что-то во время миграции?