Why?
Just because DataAccessException
abstract class . You cannot create an abstract class.
What can I do?
If you check the hierarchy:
extended by java.lang.RuntimeException extended by org.springframework.core.NestedRuntimeException extended by org.springframework.dao.DataAccessException
Since NestedRuntimeException
also abstract, you can throw new RuntimeException(msg);
(which is not recommended). You can go for something that offers a different answer. Use one of the specific classes.
source share