Home > other >  org.springframework.core.convert.ConverterNotFoundException: No converter found capable of convertin
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of convertin

Time:10-15

This is repository method, which as you will see select columns from UserDetail Entity Table by created_date, but I have getting error When I type in swagger this value 2021-10-14 23:16:31

@Query(value = "SELECT usd.phoneNumber,usd.textMessage FROM UserDetail entity usd WHERE usd.created_date=:createdDate", nativeQuery = true)
    UserDetail findByCreatedDate(LocalDateTime createdDate);

I try to type parametr String format in service layer and convert to LocalDate time like following code:

 @Override
    public UserDetail findByCreatedDateWhenUserTypeOwnInfo(String createdDate) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime dateTime = LocalDateTime.parse(createdDate, formatter);
        return this.userDetailRepository.findByCreatedDate(dateTime);
    }

I have getting this error:

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [az.expressbank.expressbankproject.data.model.UserDetail]

How to solve this problem>?

CodePudding user response:

You're using "named parameters" so looks like you need to add a @Param to your query. like this:

UserDetail findByCreatedDate(@Param("createdDate") LocalDateTime createdDate);
  • Related