1
我試圖調用MS SQL Server存儲過程。我使用彈簧引導,JPA 2.1,休眠。調用SQL Server存儲過程使用JPA 2.1註解
數據庫有ISBN,書名,作者,描述和存儲過程中我試圖調用表需要一個參數(ISBN)作爲一個字符串,並返回只有標題。
我得到以下錯誤:
org.hibernate.procedure.ParameterStrategyException:
Attempt to access positional parameter [2] but ProcedureCall using named parameters
任何人都得到一個解決方案,這或知道有什麼錯誤意味着什麼?我也嘗試了其他註釋組合。
Book.java
@Entity
@NamedStoredProcedureQuery(
name = "bookList",
resultClasses=Book.class,
procedureName = "dbo.list_books",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "isbn", type = String.class)
})
public class Book {
@Id
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
BookRepository.java
@Repository
public interface BookRepository extends CrudRepository<Book, Long> {
@Procedure
Iterable<Book> list_books(String arg);
}
BookService.java
@RestController
@RequestMapping(value = "/books", produces = MediaType.APPLICATION_JSON_VALUE)
public class BookService {
@Autowired
protected BookRepository bookRepository;
@RequestMapping
public Iterable<Book> books(){
return bookRepository.getBooks("1111111");
}