1

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 ?

Alan Hay
  • 22,665
  • 4
  • 56
  • 110
Brian Antao
  • 131
  • 2
  • 11

2 Answers2

1

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.

Brian Antao
  • 131
  • 2
  • 11
0

In addition to @Brian Antao's answer above there's some nice code for a JDBC implementation here

And if you'd like to inject a Spring datasource bean you can read how to configure it here

Which will provide easy access to your datasource, like so:

SQLServerPreparedStatement statement = (SQLServerPreparedStatement) dataSource.getConnection().prepareStatement(ececStoredProc)
Continuity8
  • 2,403
  • 4
  • 19
  • 34