spring-data-jpa 未找到能够从类型[java.math.BigInteger]转换为实体的转换器

bihw5rsg  于 2022-11-10  发布在  Spring
关注(0)|答案(2)|浏览(143)

我试图从数据库中获取交易列表,这是我面临的错误。
转换失败异常错误:无法将值'{1,1,null,null,KES,null,123456,LQALVZCFJMU 6,null,2547 XXXXXX 3,61234,加载钱包,null,null,null,null,WS 322,null}'从类型[java.lang.对象[]]转换为类型[com.钱包.发送货币.实体.事务实体];嵌套的异常是一个异常。未找到能够从类型[java.math.BigInteger]转换为类型[com.wallet.sendmoney.entities.TransactionEntity]的转换器
我使用的是JPAx 1 m0n1x注解,下面是我的存储库

@Repository
public interface TransactionsRepository extends JpaRepository<LoadWalletEntity, Long> {

@Query(value = "SELECT * FROM transactions_attempts WHERE mobile_number= :mobile_number", nativeQuery = true)
List<TransactionEntity> getAllByPhoneNumber(@RequestParam String mobile_number);
}

下面是我的实体类:

@Entity(name = "transactions_attempts")
@Table
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LoadWalletEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String currency;
@Column(name = "mobile_number")
private String mobileNumber;
private String transactionRef;
private String merchantCode;
private Integer amount;
private String networkCode;
private String reason;
private String statusCode;
private String merchantReference;
private String merchantRequestId;
private String checkoutRequestId;
private Integer resultCode;
private String resultDescription;
private String billRefNumber;
private Date transactionDate;
@Column(name = "customer_mobile")
private String customerMobile;
private String thirdPartyTransId;
}

我在这里错过了什么或做错了什么。提前感谢

qncylg1j

qncylg1j1#

您正在尝试查询TransactionEntity的列表
但您的存储库扩展为

extends JpaRepository<LoadWalletEntity, Long> {

这是什么LoadWalletEntity????
它应该

extends JpaRepository<TransactionEntity, Long> {
9lowa7mx

9lowa7mx2#

请尝试此solution

@Entity
@Table(name = "transactions_attempts")

而不是

@Entity(name = "transactions_attempts")
@Table

相关问题