我正在使用SpringBoot和JPA调用数据库,我得到的异常是
没有找到能够从类型 [位置] 转换为 [所有帐户] 类型的转换器
以下是我的代码
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>
这一行使您的存储库类只返回object Account
类型。
这就是为什么当你打电话的时候
public List<AllAccount>
findByIsActiveAndClientNameIgnoreCaseContainingOrderByAccountCreatedDesc
它试图从类型帐户
隐藏到所有帐户
,它不能,因此例外。
您可以为“所有帐户”
创建不同的存储库类,也可以通过更改为“所有帐户”来更改此存储库类以返回“所有帐户”
public interface AccountRepository extends CrudRepository<AllAccount, Integer>
我知道这是另一个类似的问题,但我自己无法回答,这就是我写信给你寻求帮助的原因。 我尝试创建自己的@Query,并在两种情况下返回一个转换错误。我的猜测是服务有问题,但这是我的知识结束。 下面是我的代码: > 主实体 2.第二种模式 3.第三种模式 存储库 @Repository public interface UserRepository extends jparepository { } 服务
我有这门课: 这个问题: 但我有这个错误
获取以下错误: 请帮我把结果设置到这个BO类中。
我将spring与JPA一起使用,并尝试使用@query与SQL query一起执行查询,并尝试将结果映射到一个对象。我有不同的实体类和映射到其他dto,因为我不想要所有的列。获取以下错误 如何解决上述问题。 如果问题无法解决,那么我们可以使用spring data JPA在不使用@Query的情况下解决问题吗?怎么做? 使用JPQL::编辑:: 获取以下错误
我必须运行一个本机查询来检索要插入到声明它的Jpa存储库以外的模型中的数据,当我执行函数loadValoriPreventivoUnica时,我有以下错误。我该如何解决这个问题?这是由于什么原因? 错误: [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap]键入[