namedNativeQuery绑定不适用于payara或Glassfish 4.1

时间:2019-01-17 12:52:06

标签: java hibernate glassfish-4 payara

这是环境设置和重要的依赖项:

  • Spring boot 1.5.6
  • dev服务器tomcat 8
  • 生产服务器Glassfish 4.1
  • org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile

以下代码在开发服务器上可以完美运行

@Entity
@Table(name = "table")
@SqlResultSetMappings({
    @SqlResultSetMapping(name = "SqlResultSetMapping.count", columns = @ColumnResult(name = "cnt")),
        @SqlResultSetMapping(name = "projection",
        classes = {
            @ConstructorResult(
                targetClass = com.considion.itas.domain.Table.class,
                columns = {})
})
@NamedNativeQueries({
    @NamedNativeQuery(
        name = "Table.request",
        resultSetMapping = "projection",
        query = "query"
    ),
    @NamedNativeQuery(
        name = "Table.request.count",
        resultSetMapping = "SqlResultSetMapping.count",
        query = " count request"
    )
})
public class Table implements Serializable { ... }

,存储库如下所示:

public interface TableRepository extends JpaRepository<Table,Long>{
    Page<Table> extract(@Param("para") ... , Pageable pageable);
}

但是一旦在生产环境中运行,glassFish会引发以下错误

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property extract found for type Table!

        at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:80) ~[spring-data-commons-1.13.15.RELEASE.jar:na]

        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:336) ~[spring-data-commons-1.13.15.RELEASE.jar:na]

        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:312) ~[spring-data-commons-1.13.15.RELEASE.jar:na]

0 个答案:

没有答案