@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 {
...
}
@Service
public 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();
}
...
}