Issue
I'm trying to get a list of transactions from database and this is the error I'm facing.
"trace": "org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [com.wallet.sendmoney.entities.TransactionEntity] for value '{1, 1, null, null, KES, null, 123456, LQALVZCFJMU6, null, 2547XXXXXX3, 61234, Load wallet, null, null, null, null, null, WS322, null}'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.math.BigInteger] to type [com.wallet.sendmoney.entities.TransactionEntity]
I'm using JPA @Query
annotation and here is my repository
@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);
}
Here is my entity class:
@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;
}
What could I be missing or doing wrong here. Thanks in advance
Solution
you are trying to query a list of TransactionEntity
but your Repository is extends with
extends JpaRepository<LoadWalletEntity, Long> {
what's this LoadWalletEntity
????
it should be
extends JpaRepository<TransactionEntity, Long> {
Answered By - James Winnchester
Answer Checked By - Marie Seifert (JavaFixing Admin)