经过数小时的尝试,我找到了使其工作的方法。
首先,我添加
@NamedStoredProcedureQuery到
CompanyResource实体类中:
CompanyResource.java
@Entity@Table(name = "company_resource")@NamedStoredProcedureQueries({ @NamedStoredProcedureQuery(name = "getAllmetalFromCompaniesByPlayerId", procedureName = "getAllmetalFromCompaniesByPlayerId", parameters = { @StoredProcedureParameter(mode = ParameterMode.IN, name = "playerId", type = Integer.class), @StoredProcedureParameter(mode = ParameterMode.OUT, name = "metalSum", type = BigDecimal.class) })})@IdClass(CompanyResourcePK.class)public class CompanyResource {...}然后我按如下
getmetalResourceByPlayerId()方式更改了我的方法
CompanyResourceServiceImpl:
CompanyResourceServiceImpl.java
@Servicepublic class CompanyResourceServiceImpl implements CompanyResourceService {@PersistenceContext private EntityManager entityManager;...private int getmetalResourceByPlayerId(int theId) { StoredProcedureQuery theQuery = entityManager.createNamedStoredProcedureQuery("getAllmetalFromCompaniesByPlayerId"); theQuery.setParameter("Param1", theId); BigDecimal outAmount = (BigDecimal) theQuery.getSingleResult(); return outAmount.intValue(); }...}


