How to call oracle predefined stored procedure which is not associated to any specific entity class.
This stored procedure does not return anything. Can this be done from spring data jpa or hibernate. If yes then how?
答案 0 :(得分:0)
hibernate-jpa
公开了一个@NamedStoredProcedureQuery
批注,您可以使用它:
@Table(name = "TableName")
@Entity
@NamedStoredProcedureQuery(
name = "proc_name",
procedureName = "proc_name",
resultClasses = {ResultDTO.class},
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, type = BigInteger.class, name = "param")
}
)
public class ResultDTO { ... }
您必须将其注释为表和实体,因此我总是只将其标记为要用作proc根目录的表。
答案 1 :(得分:0)
其中一种方法可以像使用JDBC connection
一样
connection().prepareCall("{call storedProcedureName()}").execute()
也可以从hibernate sessionFactory connection
(sessionFactory.currentSession as SessionImpl).connection().prepareCall("{call storedProcedureName()}").execute()
spring-web-hibernate的详细代码
https://gist.github.com/lynas/20d61e9b4e74155276a141a7f156bfe6