我的任务是将参数发送到数据库,并根据该参数获取数据。 我调试代码,存储库层将根据请求返回结果对象。 但是在服务层中,当它返回时会转到AopUtils.java并调用
try {
ReflectionUtils.makeAccessible(method);
return method.invoke(target, args);
}
,但未到达调用服务的控制器。 这都是关于Java反射方法调用的。
我的服务层就是这样。
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public AxiPayCustomer unSuccessfulLoginAttempts(AxiPayCustomer axipayCustomer, ServiceContext serviceContext) {
AxiPayCustomer axiPayCustomer = new AxiPayCustomer();
if(axipayCustomer.getMsisdn() == null){
throw new InvalidRequestException(getValidationFailureMessage(REQUESTED_MOBILE_NUMBER_NOT_EXIST,serviceContext));
}else {
List<Customer> customer = customerAttemptRepository.unSuccessfulLoginAttempts(axipayCustomer.getMsisdn());
if(customer == null){
throw new InvalidRequestException(getValidationFailureMessage(RETURNED_MOBILE_NUMBER_NOT_EXIST,serviceContext));
}
Customer axiPayCustomer1 = customer.get(0);
axiPayCustomer.setAttempts(axiPayCustomer1.getLoginAttempts());
return axiPayCustomer;
}
}
我的存储库层是这样的。
@Override
public List<Customer> unSuccessfulLoginAttempts(String mobileNumber) {
Session session = entityManager.unwrap(Session.class);
Criteria criteria = session.createCriteria(Customer.class, "c");
criteria.add(Restrictions.eq("c.phone1", mobileNumber));
return criteria.list();
}
控制器层
@RequestMapping(value = "/unsuccessful/login/attempts", method = RequestMethod.POST)
@ResponseBody
public Response unSuccessfulLoginAttempts(final @RequestBody LoginAttemptsRequest loginAttemptsRequest, HttpServletRequest servletRequest){
ServiceContext serviceContext = getServiceContext(loginAttemptsRequest, false);
AxiPayCustomer axiPayCustomer = new AxiPayCustomer();
BeanUtils.copyProperties(loginAttemptsRequest,axiPayCustomer);
LoggingAttemptsResponse response = new LoggingAttemptsResponse();
try{
AxiPayCustomer customerResponse = axiPayCustomerService.unSuccessfulLoginAttempts(axiPayCustomer,serviceContext);
response.setStatus(RequestStatus.SUCCESS.getStatus());
response.setMessage(customerResponse.getMessage());
response.setAttempts(customerResponse.getAttempts());
}catch (Exception e){
response.setStatus(RequestStatus.FAILURE.getStatus());
}
return response;
}
有人可以解释为什么我遇到这种问题吗?