2016-05-04 9 views
3

hier ist das Repository:aop.AopInvocationException: Null Rückgabewert von

@Query(value = "select u.balance from User u where u.name=:name") 
float toGetBalance(@Param("name") String name); 

und hier ist die DAO-Schnittstelle:

boolean checkBalance(String userName, float totalPrice); 

und hier ist der Service

@Transactional(readOnly = true) 
@Override 
public boolean checkBalance(String userName, float totalPrice) { 

    if (userRepository.toGetBalance(userName) < totalPrice) { 

     return false; 

    } else { 

     return true; 

    } 

} 

und Hier ist die Fehlerinfo:

org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract float com.repository.UserRepository.toGetBalance(java.lang.String) 

und die Art der Balance ist float!

Was ist los?

Antwort

1

Ändern Sie die Signatur Ihrer Repository

@Query(value = "select u.balance from User u where u.name=:name") 
Float toGetBalance(@Param("name") String name); 

Und es wird einfach null zurück, wenn es keine solche Benutzer in Datenbank mit bestimmten name