在网上查找我找到了注释@NamedStoredProcedureQuery
。
所以在我的实体中我定义了
@Entity
@Table(name = "Ticket_TM")
@NamedStoredProcedureQueries(
@NamedStoredProcedureQuery(
name = "getEmp",
procedureName = "GET_EMP",
returnsResultSet = false
)
)
public class MyClass implements Serializable {...}
在我的服务中,我已经定义了
@Service
public class MyService implements IMyService
{
@PersistenceContext EntityManager entityManager;
@Override
@Transactional
public void callProcedure()
{
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("getEmp");
query.execute();
log.info("Procedure executed");
}
}
但是我收到了错误
No @NamedStoredProcedureQuery was found with that name : getEmp