I warmly welcome, I'm trying to get one value from my repository. However, I have a problem at the beginning I struggled with a null pointer exeption error. Now I'm getting:
No property findbyCurrencyDTO found for type CurrencyDTO
!. I am asking for help, I tried in various ways and to no avail.
public class Conversion {
@Autowired
CurrencyRepository currencyRepository;
public String conversion () {
System.out.println(currencyRepository.findbyCurrencyDTO("PLN"));
return "ok";
}
@Repository
public interface CurrencyRepository extends JpaRepository<CurrencyDTO, Long> {
CurrencyDTO findbyCurrencyDTO(String id);
}
@Entity
@Table(name = "CurrencyDTO")
public class CurrencyDTO extends CurrencyAPIOutput implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Double cAD;
private Double hKD;
private Double pLN;
///ETC ,,
Test
public static void main(String[] args) {
SpringApplication.run(FlightRadarApplication.class, args);
Conversion conversion = new Conversion();
conversion.conversion();
}
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findbyCurrencyDTO found for type CurrencyDTO!
This error occurs because CurrencyDTO
doesn't have a CurrencyDTO
field. For instance, you can add findByCAD
. In your case, I suppose you can use JpaRepository
method findAllById
.