JPA调用Oracle存储过程

时间:2014-12-12 11:43:19

标签: java oracle jpa

在网上查找我找到了注释@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

0 个答案:

没有答案