添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type Account to type AllAccount

Ask Question

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.xxx.central.model.Account] to type [com.xxx.central.model.AllAccount]

Below is my code

Account.java

@Entity
@Table(name = "account")
public class Account implements Serializable {

AllAccount.java

@Entity(name="allAccounts")
@Table(name = "account")
public class AllAccount implements Serializable {

AccountRepository.java

@RepositoryDefinition(domainClass = Account.class, idClass = Integer.class)
public interface AccountRepository extends CrudRepository<Account, Integer> 
public List<AllAccount> 
findByIsActiveAndClientNameIgnoreCaseContainingOrderByAccountCreatedDesc(
        Boolean active, String clientNameSearchString);

When i am calling above repository from my service class i getting exception. Where i am going wrong? Thank you.

what do you have in AllAccount class? If its just a list of Account then you can try to rather return list of Account from the repository class instead of AllAccount – harsh Jun 3, 2019 at 13:49

This line makes your Repository class only return types of object Account.

That's why when you call

public List<AllAccount> 
findByIsActiveAndClientNameIgnoreCaseContainingOrderByAccountCreatedDesc

it tries to covert from type Account to AllAccount which it can't and hence the exception.

Either you create a different repository class for AllAccount or change this one to return AllAccount by changing to

public interface AccountRepository extends CrudRepository<AllAccount, Integer> 
                Thank for giving your precious time. Above solution worked for me. I created new repository class rather changing Account.                                                                                                                         Thank a lot.
– rahim
                Jun 3, 2019 at 14:49
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.