Search code examples
jpaspring-data-jpanativequery

How to pass in SQLServerDataTable object to JPA native query


I am trying to pass in a SQLServerDataTable as a Parameter to a JPA native Query.

@Query(value = "Select u FROM #{#entityName} u with (nolock) INNER JOIN :listTable pt on pt.PhoneNumber = #{#entityName}.PhoneNumber WHERE EntityType = :entityType", nativeQuery = true)
Collection<Result> findAllByEntityList(@Param("listTable") SQLServerDataTable listTable, @Param("entityType") Integer entityType);

I get the following exception:

  nested exception is org.hibernate.HibernateException: Could not determine a type for class: com.microsoft.sqlserver.jdbc.SQLServerDataTable

How do I resolve this error Please ?


Solution

  • Looks like the Spring JPA/Hibernate current implementation does not yet support passing in SQLServerDataTable as a Param.

    I got around this by doing the implementation at the JDBC layer.