我正在使用SpringBoot和JPA调用db,
我正在作为例外


  org.springframework.core.convert.ConverterNotFoundException:否
  发现能够从类型转换的转换器
  [com.xxx.central.model.Account]键入
  [com.xxx.central.model.AllAccount]


下面是我的代码

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);
}


当我从服务类中调用上述存储库时,出现异常。
我要去哪里错了?
谢谢。

最佳答案

public interface AccountRepository extends CrudRepository<Account, Integer>


此行使您的存储库类仅返回对象Account的类型。

那就是为什么当你打电话

public List<AllAccount>
findByIsActiveAndClientNameIgnoreCaseContainingOrderByAccountCreatedDesc


它试图从类型Account隐蔽到AllAccount,这是不可能的,因此是例外。

您可以为AllAccount创建另一个存储库类,或者通过更改为来更改该存储库类以返回AllAccount

public interface AccountRepository extends CrudRepository<AllAccount, Integer>

10-08 08:33